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?