Hello,
I can't get TypeMock to work properly. Maybe someone can help?
This is the code I would to mock. Unfortunately it always uses the real implementation. I'm sure I activated typeMock. In the trace I see that the mocked object is defined but never called (as far as I understand the information)
Thanks in advance for your help.
Best regards,
Alexander
....... VS2005 test framework ......
<TestMethod()> _
Public Sub HelloTest()
MockManager.Init()
Dim target As Greetings = New Greetings
Dim helloMock As Mock = MockManager.Mock(GetType(GreetingsLibrary))
helloMock.Strict = True
helloMock.ExpectConstructor()
helloMock.ExpectAndReturn("Hello", "Ann", GetType(System.String))
Dim expected As String = "Ann"
Dim actual As String
actual = target.getGreeting
Assert.AreEqual(expected, actual, "Greetings.getGreeting did not return the expected value.")
MockManager.Verify()
End Sub
End Class
Public Class Greetings
Private glib As GreetingsLibrary
Public Sub New()
glib = New GreetingsLibrary
End Sub
Public Function getGreeting() As String
Return glib.Hello
End Function
End Class
Public Class GreetingsLibrary
Public Sub New()
'intentionally
End Sub
Public Function Hello() As String
Return "world"
End Function
End Class