title: How to mock a method with multiple Ref params
body: <p>I have this method call</p>
  
  <pre><code>SecurityController.GetUserPermissions( _
       HttpContext.Current.User.Identity.Name.ToString, GroupAdmin, GroupTrans)
  </code></pre>
  
  <p>where GroupAdmin and GroupTrans are array of string and are ByRef parameters.</p>
  
  <p>So basically what it does is, given a username fill in the array of admin rights and the array of allowed transactions.</p>
  
  <p>This is legacy code that I can't change.</p>
  
  <p>here's part of my test:</p>
  
  <pre><code>var moqSecurityController = new Mock&lt;ISecurityController&gt;();
  var refParam = new string[1] {"test"};
  moqSecurityController
     .Setup(x =&gt; x.GetUserPermissions("Bob", ref refParam, ref refParam))
     .Callback((string userName, string[] groupAdmin, string[] groupTrans) =&gt;
                                                   {
                                                      groupAdmin[0] = "Test a";
                                                      groupTrans[0] = "Test b";
                                                   });
  </code></pre>
  
  <p>at the end I would expect to have "test" in both GroupAdmin and GroupTrans, but I'm getting
  an error:</p>
  
  <pre><code>Invalid callback. Setup on method with parameters (String,String[]&amp;,String[]&amp;)
  cannot invoke callback with parameters (String,String[],String[])
  </code></pre>
  
  <p>What am I missing? Can anyone please help me mock this?</p>
  
  <p>Thanks</p>