When working with Rhino.Mocks with a mock object in hand:
Is there a way to pass a unit-test once an expected method is called without executing the lines after the call to this expected method?
Thanks
Since RhinoMocks 3.5 you can use nice AssertWasCalled()
this.Service.BuldMessage("messageId");
this.Service.AssertWasCalled(x => x.GenerateMessage("messageId"), messageId));
EDIT: Answer to comment
RhinoMock is not in charge to change test execution flow, so you have to use NUnit asserts, Assert.Pass() utility method allows you to immediately end the test, recording it as successful:
if (this.Service.AssertWasCalled(...)))
{
Assert.Pass("well done");
}
PS: as others suggested consider redesing of unit test which forced you to do such conditional test exit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With