title: Calling same method multiple times with different returns using MOQ
body: <p>I am writing a unit test case where I need to rollback the first payment when the first payment is a success and the second payment fails. The unit test code looks like the following:</p>
  
  <ol>
  <li>Process first payment successfully.</li>
  <li>Process second payment. External system will throw similar transaction fault exception. Parse similar transaction fault exception to get exceptionid and process second transaction again, using the exception id. </li>
  <li>When the second transaction is actually processed, the system returns a "Payment declined fault exception". </li>
  <li>The system should then void the first payment.   </li>
  </ol>
  
  <p>I have written the unit test for (1). How SO community have pointers on how to take care of part 2, 3, 4? </p>
  
  <pre><code>        [TestMethod]    
              public void IfTheSecondPaymentFailsThenTheFirstPaymentShouldBeVoided()
              {
  //Arrange        
          var iPaymentMock = new Mock&lt;IPaymentMock&gt;();
                  var paymentSpecificationResponse = new PreregisteredAccountSpec();    
                  iPaymentMock.Setup(
                          counter =&gt; counter.ProcessPayment
                              (
                                  It.IsAny&lt;Context&gt;(),
                                  It.IsAny&lt;PreregisteredAccountSpec&gt;(),  
                                  It.IsAny&lt;Guid&gt;())
                              ).
                          Returns(paymentSpecificationResponse);  
  //Act
  var twoPaymentProcessor = new TwoPaymentProcessor(iPaymentMock.Object);
  twoPaymentProcessor.Submit();
  
  //assert
       iPaymentMock.Verify((
                      counter =&gt; counter.ProcessPaymentSpecification
                      (
                          It.IsAny&lt;Context&gt;(),
                          It.IsAny&lt;PreregisteredAccountSpec&gt;(),  
                          It.IsAny&lt;Guid&gt;()
                      )
                  ), Times.Once());  
              }
  </code></pre>