Good point. What should be the expected behavior?
/kzu from mobile
When using a "MockSequence" the behavior of the "VerifyAll" method is modified. Is this correct?
public interface IFoo { void Do(); } /* * Throws MockVerificationException */ var foo = new Mock<IFoo>(MockBehavior.Strict); foo.Setup(f => f.Do()); foo.VerifyAll(); /* * Does not throw MockVerificationException */ var foo = new Mock<IFoo>(MockBehavior.Strict); var seq = new MockSequence(); foo.InSequence(seq).Setup(f => f.Do()); foo.VerifyAll();—
Reply to this email directly or view it on GitHub.
The previous examples were not very good because I've just described the behavior that is already correct.
The following example demonstrates how a "MockSequence" causes the "VerifyAll" method to be less restrictive, while in my opinion, it should be more restrictive.
/* * Does not throw MockVerificationException, but in my opinion it should */ var foo = new Mock<IFoo>(MockBehavior.Strict); var seq = new MockSequence(); foo.InSequence(seq).Setup(f => f.DoOne()); foo.InSequence(seq).Setup(f => f.DoTwo()); var obj = foo.Object; obj.DoOne(); foo.VerifyAll();