The Return()
method is not valid for calling the void method. Rather, you want something like this:
ICar stubCar= MockRepository.GenerateStrictMock<ICar>(); stubCar.Expect(c=>c.Horn()); stubCar.DoSomethingThatIsSupposedToCallHorn(); stubCar.VerifyAllExpectations();
which will tell you if Horn()
called.
The way you test that void methods are called during unit testing. You do the following:
- Set Expectation (
Expect()
) - Call the method that should be waiting
- Verify that the expected method is being called.
source share