public void WillRememberExceptionInsideOrderRecorderEvenIfInsideCatchBlock() { MockRepository mockRepository = new MockRepository(); IInterfaceWithThreeMethods interfaceWithThreeMethods = mockRepository.StrictMock <IInterfaceWithThreeMethods>(); using (mockRepository.Ordered()) { interfaceWithThreeMethods.A(); interfaceWithThreeMethods.C(); } mockRepository.ReplayAll(); interfaceWithThreeMethods.A(); try { interfaceWithThreeMethods.B(); } catch { /* valid for code under test to catch all */ } interfaceWithThreeMethods.C(); Assert.Throws <ExpectationViolationException>( "Unordered method call! The expected call is: 'Ordered: { IInterfaceWithThreeMethods.C(); }' but was: 'IInterfaceWithThreeMethods.B();'", () => mockRepository.VerifyAll()); }
public void WillRememberExceptionInsideOrderRecorderEvenIfInsideCatchBlock() { IInterfaceWithThreeMethods interfaceWithThreeMethods = MockRepository.Mock <IInterfaceWithThreeMethods>(); interfaceWithThreeMethods.Expect(x => x.A()); interfaceWithThreeMethods.Expect(x => x.C()); interfaceWithThreeMethods.A(); interfaceWithThreeMethods.B(); interfaceWithThreeMethods.C(); Assert.Throws <ExpectationViolationException>(() => interfaceWithThreeMethods.VerifyExpectations(true)); }