Faking Non-Public Ref and Out Parameters
To return Ref and Out parameters of non-public methods, set the value of these arguments before faking the call to the method.
When to Use
When your test requires a specific return value from Ref and Out parameters.
Syntax
C# var fakeParam = <result>; Isolate.NonPublic.WhenCalled<Dependency>("method").AssignRefOut(fakeParam).<bahavior>;
VB
Dim fakeParam = <result>
Isolate.NonPublic.WhenCalled(Of Dependency)("method").AssignRefOut(fakeParam).<bahavior>
Samples
C# [TestMethod, Isolated] public void VerifyPrivateStaticMethodWithRef_Return() { int fakeParam = 3; Isolate.NonPublic.WhenCalled<Dependency>("PrivateMethodOutParam").AssignRefOut(fakeParam).IgnoreCall(); var result = Dependency.CallPrivateMethodOutParam(); Isolate.Verify.NonPublic.WasCalled(typeof(Dependency), "PrivateMethodOutParam"); Assert.AreEqual(3, result); }
VB
<TestMethod, Isolated>
Public Sub VerifyPrivateStaticMethodWithRef_Return()
Dim fakeParam As Integer = 3
Isolate.NonPublic.WhenCalled(Of Dependency)("PrivateMethodOutParam").AssignRefOut(fakeParam).IgnoreCall()
Dim result = Dependency.CallPrivateMethodOutParam()
Isolate.Verify.NonPublic.WasCalled(GetType(Dependency), "PrivateMethodOutParam")
Assert.AreEqual(3, result)
End Sub