title: Moq callback not modifying input parameters
body: <p><strong>The problem:</strong></p>
  
  <p>The code below does not allow me to modify the parameters that I pass into a method that has been mocked with Moq.</p>
  
  <p><strong>Additional details:</strong></p>
  
  <p>I am attempting to mock a generic data access object that provides a method called <code>ExecuteStoredProcedureWithParameters</code>.  The method accepts two parameters: a stored procedure name and a collection of <code>SqlParameter</code> objects.  I have stored procedures that return values via output parameters, so I am attempting to mock the data access method and modify the value of the output parameter (which is a member of the <code>SqlParameter</code> collection that gets passed in).  From my research, the code I have below seems like it should work (I'm just attempting to modify the input parameters by setting them to empty/null for testing purposes).  The return value I specified in my mock setup gets returned and stored in <code>retval</code>, however the values of <code>testProcedure</code> and <code>testParameters</code> remain unchanged after the mock method is executed.  What am I doing wrong and how can I modify the objects that are passed into my mock method? </p>
  
  <p><strong>My interface:</strong></p>
  
  <pre><code>public interface IGenericDAO
  {
      int ExecuteStoredProcedureWithParameters(string procedureName, Collection&lt;SqlParameter&gt; parameters);
  }
  </code></pre>
  
  <p><strong>Test method:</strong></p>
  
  <pre><code>// Create a mock generic DAO
  var mock = new Mock&lt;IGenericDAO&gt;();
  mock.Setup(x =&gt; x.ExecuteStoredProcedureWithParameters("TestProcedure", It.IsAny&lt;Collection&lt;SqlParameter&gt;&gt;()))
      .Returns(111)
      .Callback&lt;string, Collection&lt;SqlParameter&gt;&gt;((proc, prms) =&gt; { proc = string.Empty; prms = null; });
  
  // Execute the mocked method with dummy parameters
  var testProcedure = "TestProcedure";
  var testParameters = new Collection&lt;SqlParameter&gt;();
  var retval = mock.Object.ExecuteStoredProcedureWithParameters(testProcedure, testParameters);
  </code></pre>