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?