title: PrivateObject wont return out parameter
body: <p>I'm trying to test private methods in a Unit test project. So far it's going great, but I hit a bump, when I have to test a method with an out parameter. The signature for that method is:</p>
  
  <pre><code>private bool GotSSI(out SSI ssi, RSI rsi)
  {
          ~code omitted~
  }
  </code></pre>
  
  <p>And the unittest (the part that is not working) looks like this:</p>
  
  <pre><code>SSI ssi = null;
  object[] p = new object[]{ssi,rsi};
  Type[] t = new Type[] { typeof(SSI).MakeByRefType(), typeof(RSI) };
  actual = (bool) privateTarget.Invoke("GotSSI",t,p);
  </code></pre>
  
  <p>The GotSSI method work. I've tested it in debug mode within the unit test and I can see that the 'ssi' out variable is set inside the method, before returning it's true or false value. But when the test returns to it's own code, the 'ssi' variable is still null. So the problem is that the object I created in the "GotSSI" method, is not parsed out of the PrivateObject invoke method.</p>
  
  <p>Anyone knows what I am missing?</p>
  
  <p><strong>Update (Solution by Rafal)</strong></p>
  
  <p>Rafal's solution work perfectly and here is how I implemented the solution.</p>
  
  <p>I created a delegate:</p>
  
  <pre><code>delegate bool GotSSIInternal(out SSI ssi, RSI rsi);
  </code></pre>
  
  <p>And when I have created the object I wanted to test, I build the delegate (target is the object i'm testing):</p>
  
  <pre><code>GotSSIInternal gotSSIInternal = (GotSSIInternal) Delegate.CreateDelegate(
              typeof (GotSSIInternal), 
              target,
              typeof(OfflineResolver).GetMethod("GotSSI", BindingFlags.NonPublic | BindingFlags.Instance));
  </code></pre>
  
  <p>After that is very simple to call the delegate:</p>
  
  <pre><code>actual = gotSSIInternal.Invoke(out ssi, rsi);
  </code></pre>
  
  <p>The solution is very simple and works like a charm.</p>