Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 151663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:29:08+00:00 2026-05-11T09:29:08+00:00

I have a class that acts like this at the moment: public class MyClass

  • 0

I have a class that acts like this at the moment:

public class MyClass {      public void Method1(){         if (false) {             Method2();         }     }      public void Method2(){         //do something here     } } 

So Method2 is never called (my code looks a bit different but I have this if-clause that evaluates to false and therefore doesn’t execute the Method2. Checked it by debugging to be sure). I want to tell RhinoMocks that I expect Method2 to be called and the test to fail:

MockRepository mock = new MockRepository(); MyClass presenter = mock.PartialMock<MyClass>();  Expect.Call(() => presenter.Method2()).IgnoreArguments();  mock.ReplayAll(); presenter.Method1(); mock.VerifyAll(); 

…but the test passes.

(The reason for the lambda expression in the Expect.Call is, that my actual Method2 has arguments)

My questions:

  • Is this the usual approach for testing in this scenario? (I’m just starting with RhinoMocks and mocking-frameworks in general)
  • Why does the test pass?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:29:08+00:00Added an answer on May 11, 2026 at 9:29 am

    As confirmed by Jakob’s comments, PartialMock only mocks abstract/virtual methods, so your expectation isn’t actually doing anything.

    Personally I don’t generally mock out methods within the class I’m testing. I just mock out dependencies, and express those through interfaces instead of concrete classes, avoiding this problem to start with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have class that looks like this: class A { public: class variables_map vm
I have a class which contains a static field that acts like a singleton
At work we have a base class, let's call it IntrusiveBase, that acts something
I have a Class that has a private variable with a public setter/getter function:
I have a class that I want to contain multiple objects of something I
I have a class that acts as a wrapper to Smarty but want to
I want to write a container class that acts like a dictionary (actually derives
I have a list like this: <ul> <li id=adm-thumb onclick=javascript:addBanner('bowling.jpg');> <div class=adm-tick></div> <img src=img/banners/bowling.jpg
I have a question about Java Generics. If I define a class like this:
I have a class that essentially acts as a light weight wrapper class around

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.