Moq/moq4 — pull request #130 by grzesiek-galezowski (2014-09-02 22:10:26+00:00)
Title: Minimal call sequence verification implementation

This is the best API I could come up so far. An example of proposed syntax would be something like this:

var sequence = new CallSequence();
var mock1 = new Mock { CallSequence = sequence };
var mock2 = new Mock { CallSequence = sequence };
var mock3 = new Mock();

mock1.Object.Do();
mock3.Object.Do();
mock2.Object.Do();

CallSequence.Verify(
mock1.CallTo(a => a.Do()),
mock2.CallTo(b => b.Do())
);

Regarding discussion in issue #21 :

1. Removed "verify not in sequence" feature for now
2. Changes CallSequence to take parameter of MockBehavior

var m1 = new Mock()
{ CallSequence = new CallSequence(MockBehavior.Loose) };

3. Introduced a shortcut in CallSequence when all mocks have the same sequence:

CallSequence.Verify(
m1.CallTo(m => m.Do()),
m2.CallTo(m => m.Do()))
);

A method is exposed on sequence object should anyone require checking more than one sequence:

sequence.VerifyCalls(
m1.CallTo(m => m.Do()),
m2.CallTo(m => m.Do()))
);

4. Moved the sequencing feature (along with `CallTo...` extension methods) to a separate namespace
5. Introduced extension points but for now they are hidden because I have no good idea yet on how to deal with Times.XYZ() - for sequences, this is non-trivial, especially when taking into account few combined "at least" and "at most" checks.
6.Exposed CallSequence on MockRepository