title: Moq callback with out parameter
body: <p>I'm trying to use Moq to mock a callback for the following method signature:</p>
  
  <pre><code>ResponseHeader AddIncentives(
          Hs_transRow[] data,
          out ResponseBody responseBody);
  </code></pre>
  
  <p>I want my callback to use the data which is passed in. However, I'm running into problems which I think are because the second parameter is an out parameter. I can setup and return data without problems, but the callback is an issue.</p>
  
  <p>This is my current setup:</p>
  
  <pre><code>var addIncentiveResponseBody = new ResponseBody();
  
  mockCoinsService
  .Setup(service =&gt; service.AddIncentives(It.IsAny&lt;Hs_transRow[]&gt;(), out addIncentiveResponseBody))
  .Callback((Hs_transRow[] data, ResponseBody body) =&gt;
  {
      //I want to use the data variable here
  })
  .Returns(() =&gt; new ResponseHeader
  {
       action = ResponseHeaderAction.RESPONSE,
  });
  </code></pre>
  
  <p>When I run this code as part of a unit test, I get the error:</p>
  
  <blockquote>
    <p>Invalid callback. Setup on method with parameters (Hs_transRow[],ResponseBody&amp;) cannot invoke callback with parameters (Hs_transRow[],ResponseBody).</p>
  </blockquote>
  
  <p>I can see there is an ampersand difference, which I assume is because that parameter should be an out parameter. However, if I add the out keyword to the  callback (and assign it a value within the callback), I get the build time error:</p>
  
  <blockquote>
    <p>Delegate 'Action' does not take two arguments.</p>
  </blockquote>
  
  <p>Is Moq unable to handle a callback for a method which has an out parameter, or am I doing something wrong?</p>
  
  <p>[Edit] To clarify beyond any doubt, I am not asking how to set the value of the out parameter. This is already being done by the line:</p>
  
  <pre><code>var addIncentiveResponseBody = new ResponseBody();
  </code></pre>