It would be usefull for us on learning curves to have some examples supplied with the download or as a separate download. I have been trying to get it to work with vb.net , altho I am a c# developer and the syntax has been driving me crazy. Some example code always makes life easier.
Hi Owain,
It is true that we don't have VB.NET code example in the distribution, we will try to add example source code in c# and VB.NET.
Here is a small VB.NET example:
<TestFixture()> _
Public Class Test
' Initialize before each test
<SetUp()> _
Public Sub SetUp()
MockManager.Init()
End Sub
' Verfiy after each test
<TearDown()> _
Public Sub TearDown()
MockManager.Verify()
End Sub
' Test some expectations,
<Test()> _
Public Sub ReturnValue()
Dim t As TestedClass
Dim mock As Mock
' Mock the type and set expectations
mock = MockManager.Mock(GetType(TestedClass))
mock.ExpectAndReturn("getVar", 5)
mock.ExpectAndReturn("getVar", 6)
mock.ExpectGet("Str", "Hi")
' Perform the code
t = New TestedClass
Assert.AreEqual("Hi", t.Str())
Assert.AreEqual(5, t.getVar())
Assert.AreEqual(6, t.getVar())
End Sub
' Test the passed arguments expectations,
<Test()> _
Public Sub TestParameters()
Dim t As TestedClass
Dim mock As Mock
' Mock the type and set expectations with argument checks
mock = MockManager.Mock(GetType(TestedClass))
mock.ExpectAndReturn("DoSomething", 1).Args("s", 9.3F, MockManager.Any, True)
' Perform the code
t = New TestedClass
Assert.AreEqual(1, t.DoSomething("s", 9.3F, "a", True))
End Sub