How to pass unit test immediately after calling the expected method on the object layout?

When working with Rhino.Mocks with a mock object in hand:

Is there a way to pass the unit test after calling the expected method without executing the lines after calling this expected method?

thank

+5
source share
2 answers

With RhinoMocks 3.5 you can use nice AssertWasCalled()

this.Service.BuldMessage("messageId");
this.Service.AssertWasCalled(x => x.GenerateMessage("messageId"), messageId));

EDIT: reply to comment

RhinoMock is not responsible for changing the flow of the test, so you need to use NUnit statements. The Assert.Pass () utility method allows you to complete the test immediately, making it successful:

if (this.Service.AssertWasCalled(...)))
{
   Assert.Pass("well done");
}

PS: unit test, .

+2

AssertWasCalled() Rhino.Mocks

, , , , . (Nunit ) . , , . . . , .

, , , , . , , .

+2

All Articles