Question: How do I create unit tests for out parameters of a private function?

My service layer:

```
private int LoadProduct(string productId, out IProduct product)
{
    product = this.Load(productId);

    return ErrorCodes.Success;
}

```

Test case:

```
[Test]
public void LoadProductTest()
{
    var offerService = new OfferProcessor();
    var privateOfferService = new PrivateObject(offerService);

    IProduct myProduct = null;

    var result = (int)privateOfferService.Invoke("LoadProduct", 
                       new object[] {"AnId", myProduct });

    Assert.That(result, Is.EqualTo(ErrorCodes.Success));
    Assert.That(myProduct, Is.NotNull());
}

```

The above test case does not compile. How do I pass Invoke an out parameter and then access it after the call?

Answer: 
try saving the object array that you pass the invoke call.

```
object[] args = new object[] { "AnId", myProduct };
var result = (int)privateOfferService.Invoke("LoadProduct", args);
Assert.That(args[1], Is.NotNull());

```

<https://stackoverflow.com/a/2438069/1311351>
You can, if you really, really need to test this method, mark it internal and specify the [InternalsVisibleTo](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx) attribute for the class to your test namespace. But yeah, just test the public interface.