title: Verifying in Sequence
body: <p>I am trying to verify a set of method calls in sequence.</p>
  
  <p>Here is a sample of what I would like to do. This test should fail, but it actually passes:</p>
  
  <pre><code>    public interface IMyInterface
      {
          void Method(int i);
      }
  
      public class MyClass : IMyInterface
      {
          public void Method(int i)
          {
          }
      }
  
      [TestMethod]
      public void MyTestMethod()
      {
          var mock = new Mock&lt;IMyInterface&gt;();
  
          var listOfThings = new List&lt;int&gt; { 5, 4, 3, 2, 1 };
  
          MethodUnderTest(mock.Object, listOfThings);
  
          mock.Verify(m =&gt; m.Method(1));
          mock.Verify(m =&gt; m.Method(2));
          mock.Verify(m =&gt; m.Method(3));
          mock.Verify(m =&gt; m.Method(4));
          mock.Verify(m =&gt; m.Method(5));
      }
  
      public void MethodUnderTest(IMyInterface myInterface, List&lt;int&gt; things)
      {
          foreach (var i in things)
          {
              myInterface.Method(i);
          }
      }
  </code></pre>
  
  <p>This should fail, as the <code>Verify</code> calls expect a different order of parameters.</p>
  
  <p>I have tried <code>MockSequence</code> like this:</p>
  
  <pre><code>    [TestMethod]
      public void MyTestMethod()
      {
          var mock = new Mock&lt;IMyInterface&gt;();
  
          var listOfThings = new List&lt;int&gt; { 5, 4, 3, 2, 1 };
  
          var s = new MockSequence();
  
          mock.InSequence(s).Setup(m =&gt; m.Method(1));
          mock.InSequence(s).Setup(m =&gt; m.Method(2));
          mock.InSequence(s).Setup(m =&gt; m.Method(3));
          mock.InSequence(s).Setup(m =&gt; m.Method(4));
          mock.InSequence(s).Setup(m =&gt; m.Method(5));
  
          MethodUnderTest(mock.Object, listOfThings);
  
          mock.Verify(m =&gt; m.Method(1));
          mock.Verify(m =&gt; m.Method(2));
          mock.Verify(m =&gt; m.Method(3));
          mock.Verify(m =&gt; m.Method(4));
          mock.Verify(m =&gt; m.Method(5));
      }
  </code></pre>
  
  <p>But I guess I'm doing this wrong.</p>
  
  <p>Using <code>MockBehaviour.Strict</code> doesn't seem to work either:</p>
  
  <pre><code>    [TestMethod]
      public void MyTestMethod()
      {
          var mock = new Mock&lt;IMyInterface&gt;(MockBehavior.Strict);
  
          var listOfThings = new List&lt;int&gt; { 5, 4, 3, 2, 1 };
  
          mock.Setup(m =&gt; m.Method(1));
          mock.Setup(m =&gt; m.Method(2));
          mock.Setup(m =&gt; m.Method(3));
          mock.Setup(m =&gt; m.Method(4));
          mock.Setup(m =&gt; m.Method(5));
  
          MethodUnderTest(mock.Object, listOfThings);
  
          mock.Verify(m =&gt; m.Method(1));
          mock.Verify(m =&gt; m.Method(2));
          mock.Verify(m =&gt; m.Method(3));
          mock.Verify(m =&gt; m.Method(4));
          mock.Verify(m =&gt; m.Method(5));
      }
  </code></pre>
  
  <p>I can't use a <code>Setup</code> to configure the parameters passed into the mock call, as these values do not come from a mockable source.</p>