thank you very much for your answers .
it really helps me .
your example in the last post works very well.
and It also works as well like this.
'Production code
Public Class A
Public Function Method(ByRef b As Integer) As Int32
Return 1
End Function
Public Function MyTest() As Integer
Dim a As Integer = 23
Dim b As Integer = 4
a = Method(b)
Return a
End Function
' Test Code
Dim fake As A = FakeInstance(Of A)(Members.CallOriginal)
'Isolator API for non public
NonPublicWillReturn(fake, "Method", 5)
Dim actualResult= fake.MyTest()
Assert.AreEqual(5, actualResult)
howevery ,when I test like this ,I could not get the expected value.
I turned the method of Class A to
"private"
' Production Code
Public Class A
Private Function Method(ByRef b As Net.HttpWebRequest) As B
Dim test = New B
test.x = 1
Return test
End Function
Private Function MyTest() As B
Dim test = New B
test.x = 23
Dim l_httpWebRequest As Net.HttpWebRequest = Nothing
test = Method(l_httpWebRequest)
Return test
End Function
End Class
Public Class B
Public x As Int32
End Class
' Test Code
Dim fake As A_Accessor = FakeInstance(Of A_Accessor)(Members.CallOriginal)
'Isolator API for non public
Dim test = New B
test.x = 5
NonPublicWillReturn(fake, "Method", test)
Dim actualResult = fake.MyTest()
Assert.AreEqual(5, actualResult.x)
the "Method" was called and actualResult.x is "1".
could you please tell me why ?
sorry to waste you so much time .