title: Using Moq to Validate Separate Invocations with Distinct Arguments
body: <p>I'm trying to validate the values of arguments passed to subsequent mocked method invocations (of the same method), but cannot figure out a valid approach.  A generic example follows:</p>
  
  <pre><code>public class Foo
  {
      [Dependency]
      public Bar SomeBar
      {
          get;
          set;
      }
  
      public void SomeMethod()
      {
          this.SomeBar.SomeOtherMethod("baz");
          this.SomeBar.SomeOtherMethod("bag");
      }
  }
  
  public class Bar
  {
      public void SomeOtherMethod(string input)
      {
      } 
  }
  
  public class MoqTest
  {
      [TestMethod]
      public void RunTest()
      {
          Mock&lt;Bar&gt; mock = new Mock&lt;Bar&gt;();
          Foo f = new Foo();
          mock.Setup(m =&gt; m.SomeOtherMethod(It.Is&lt;string&gt;("baz")));
          mock.Setup(m =&gt; m.SomeOtherMethod(It.Is&lt;string&gt;("bag"))); // this of course overrides the first call
          f.SomeMethod();
          mock.VerifyAll();
      }
  }
  </code></pre>
  
  <p>Using a Function in the Setup might be an option, but then it seems I'd be reduced to some sort of global variable to know which argument/iteration I'm verifying.  Maybe I'm overlooking the obvious within the Moq framework?</p>