title: How to test method call order with Moq
body: <p>At the moment I have:</p>
  
  <pre><code>    [Test]
      public void DrawDrawsAllScreensInTheReverseOrderOfTheStack() {
          // Arrange.
          var screenMockOne = new Mock&lt;IScreen&gt;();
          var screenMockTwo = new Mock&lt;IScreen&gt;();
          var screens = new List&lt;IScreen&gt;();
          screens.Add(screenMockOne.Object);
          screens.Add(screenMockTwo.Object);
          var stackOfScreensMock = new Mock&lt;IScreenStack&gt;();
          stackOfScreensMock.Setup(s =&gt; s.ToArray()).Returns(screens.ToArray());
          var screenManager = new ScreenManager(stackOfScreensMock.Object);
          // Act.
          screenManager.Draw(new Mock&lt;GameTime&gt;().Object);
          // Assert.
          screenMockOne.Verify(smo =&gt; smo.Draw(It.IsAny&lt;GameTime&gt;()), Times.Once(),
              "Draw was not called on screen mock one");
          screenMockTwo.Verify(smo =&gt; smo.Draw(It.IsAny&lt;GameTime&gt;()), Times.Once(), 
              "Draw was not called on screen mock two");
      }
  </code></pre>
  
  <p>But the order in which I draw my objects in the production code does not matter. I could do one first, or two it doesn't matter. However it should matter as the draw order is important.</p>
  
  <p>How do you (using Moq) ensure methods are called in a certain order?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I got rid of that test. The draw method has been removed from my unit tests. I'll just have to manually test it works. The reversing of the order though was taken into a seperate test class where it was tested so it's not all bad.</p>
  
  <p>Thanks for the link about the feature they are looking into. I sure hope it gets added soon, very handy.</p>