I'm testing that a helper I wrote calls a lambda with specific arguments in a specific order, which is what MockSequence is supposed to enforce. However, I don't get an exception if I add Setup steps to the sequence that are not called. I want that to be flagged as a failure.
[Test]
public void Move_B_C_H_before_F_in_given_order() {
var input = new List<char> { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
var mock = new Mock<Action<int, int>>(MockBehavior.Strict);
var seq = new MockSequence();
mock.InSequence(seq).Setup(x => x(7, 5));
mock.InSequence(seq).Setup(x => x(1, 5));
mock.InSequence(seq).Setup(x => x(1, 5));
mock.InSequence(seq).Setup(x => x(2, 5));
ReorderingHelper.ReorderPages(
[7, 1, 2],
5,
mock.Object,
orderSelectedIndicesAscending: false
);
// ^ passes, but was not called with 2,5!
}
The test should fail unless all specified setups in the sequence were called.
Describe the Bug
I'm testing that a helper I wrote calls a lambda with specific arguments in a specific order, which is what
MockSequenceis supposed to enforce. However, I don't get an exception if I addSetupsteps to the sequence that are not called. I want that to be flagged as a failure.Steps to Reproduce
Expected Behavior
The test should fail unless all specified setups in the sequence were called.