在Rhino-mocks 3.6中,如果Method1称为1st,然后调用Method2,然后使用AAA语法使用Method3,则可以测试以下示例?
// Assert var mock = MockRepository.GenerateMock<ISomeService>(); // Act myObject.Service = mock; // How should I change this part to ensure that Rhino Mocks check the call order as well? mock.AssertWasCalled(m=>m.Method1()); mock.AssertWasCalled(m=>m.Method2()); mock.AssertWasCalled(m=>m.Method3());
解决方法
这里有一种做法吗?
mock.AssertWasCalled(m=>m.Method1(),options => options.WhenCalled(w => mockService.AssertWasNotCalled(x=>x.Method2()))); mock.AssertWasCalled(m=>m.Method2(),options => options.WhenCalled(w => mockService.AssertWasNotCalled(x=>x.Method3()))); mock.AssertWasCalled(m=>m.Method3());