title: MOQ - setting up a method based on argument values (multiple arguments)
body: <p>I have an interface defined as </p>
  
  <pre><code>interface IMath
  {
   AddNumbersBetween(int lowerVal, int upperVal);
  }
  </code></pre>
  
  <p>I can setup a basic Moq for the above as follows:</p>
  
  <pre><code>Mock&lt;IMath&gt; mock = new Mock&lt;IMath&gt;();    
  mock.Setup(m =&gt; m.AddNumbersBetween(It.IsAny&lt;int&gt;(), It.IsAny&lt;int&gt;()));
  </code></pre>
  
  <p>call it</p>
  
  <pre><code>mock.Object.AddNumbersBetween(1,4);
  </code></pre>
  
  <p>and then verify that it was called</p>
  
  <pre><code>mock.Verify(m =&gt; m.AddNumbersBetween(1,4), Times.AtleastOnce());
  </code></pre>
  
  <p>I cant figure out how to setup the method AddNumbersBetween such that if the upperVal is lower than the lowerVal an exception is thrown</p>
  
  <pre><code>mock.Object.AddNumbersBetween(4,1);//should throw an exception
  </code></pre>
  
  <p>Essentially looking for something like:</p>
  
  <pre><code>mock.Setup(foo =&gt; foo.AddNumbersBetween("arg1 is higher than arg2")).Throws&lt;ArgumentException&gt;();
  </code></pre>