title: Assigning out parameters in Moq for methods that return void
body: <p>In <a href="https://stackoverflow.com/questions/1068095/assigning-out-ref-parameters-in-moq">this question</a>, I found an <a href="https://stackoverflow.com/a/19598345/1591992">this answer</a> that seems to be the best way to solve the problem to me. </p>
  
  <p>The provided code assumes that the function that is mocked returns a value: </p>
  
  <pre><code>bool SomeFunc(out ISomeObject o);
  </code></pre>
  
  <p>However, the object I want to mock has an out function as follows: </p>
  
  <pre><code>void SomeFunc(out ISomeObject o);
  </code></pre>
  
  <p>The relevant code fragment from the mentioned answer:</p>
  
  <pre><code>public delegate void OutAction&lt;TOut&gt;(out TOut outVal);
  
  public static IReturnsThrows&lt;TMock, TReturn&gt; OutCallback&lt;TMock, TReturn, TOut&gt;(
      this ICallback&lt;TMock, TReturn&gt; mock, OutAction&lt;TOut&gt; action)
      where TMock : class
  {
      // ...
  }
  </code></pre>
  
  <p>Void is not a valid type for TReturn. So I believe I would have to somehow adapt this code to get it to work with methods returning void. But how? </p>