title: Mock up a method with ref parameter to return specific value
body: <p>I am using Moq on my .NET Project for Unit Testing my code and
  I am trying to mock one of my services which has method with <em>ref</em> parameter and return a specific result.</p>
  
  <p>Service code:</p>
  
  <pre><code>public bool CallServiceFunctionTest(IList&lt;TestObject&gt; test, ref IList&lt;TestObjectErrors&gt; errors)
  {
      //...
      return !errors.Any();
  }
  </code></pre>
  
  <p>Controller code:</p>
  
  <pre><code>var test = _dataUnitOfWork.TestRepository.GetTest(id);
  IList&lt;TestObjectErrors&gt; errors = new List&lt;TestObjectErrors&gt;();
  var testingResponse = service.CallServiceFunctionTest(test, errors);
  </code></pre>
  
  <p>TestController code:</p>
  
  <pre><code>IList&lt;TestObject&gt; fakeObjects = new List&lt;TestObject&gt;()
  {
      new TestObject(){Id = 1 , Name = 'Test'}
  };
  
  _dataUnitOfWork.Setup(x =&gt; x.TestRepository.GetTest(1, null)).Returns(Task.FromResult(fakeObjects));
  IList&lt;TestObjectErrors&gt; errors = new It.IsAny&lt;IList&lt;TestObjectErrors&gt;&gt;();
  _service.Setup(x =&gt; x.CallServiceFunctionTest(fakeObjects, ref errors)).Returns(true);
  </code></pre>
  
  <p>And also tried with same instances as the real call because of the GitHub moq page:</p>
  
  <pre><code>IList&lt;TestObjectErrors&gt; errors = new List&lt;TestObjectErrors&gt;();
  _service.Setup(x =&gt; x.CallServiceFunctionTest(fakeObjects, ref errors)).Returns(true);
  </code></pre>
  
  <p>I read some solutions and try with a callback, without specific parameters but I still don't get the 'true' result.I am sure that I am missing something but I don't know what.I tried also the solution in the moq page in GitHub but without result, here is the ref = > <a href="https://github.com/moq/moq4/wiki/Quickstart" rel="nofollow noreferrer">Moq Quickstart</a></p>