moq Tutorial => Validating call order with MockSequence
riptutorial.com › moq › exampleMoq provides support for validating call order using MockSequence, however it only works when using Strict mocks. So, Given the following method to test: public void MethodToTest () { _utility.Operation1 ("1111"); _utility.Operation2 ("2222"); _utility.Operation3 ("3333"); } It can be tested as follows: // Create the mock, not MockBehavior.Strict tells the mock how to behave var utilityMock = new Mock<IUtility> (MockBehavior.Strict); // Create the MockSequence to validate the call order var ...
Verify calls are made in the correct order #748 - GitHub
github.com › moq › moq4Feb 14, 2019 · Short of MockSequence, Moq currently has no other built-in API that would allow you to verify proper invocation order across several mocks. If you cannot, or don't want to, use MockSequence , you'll have to work around this using a counter and/or .Callback() (which is what MockSequence and the Moq.Sequences NuGet package I mentioned above do under the hood).