The following C# code works just fine and the test passes as expected.
using NUnit.Framework;
using Rhino.Mocks;
namespace RhinoMocksTesting
{
public interface ITesting
{
string Test { get; }
}
[TestFixture]
public class MocksTest
{
[Test]
public void TestMockExpect()
{
var mocks = new MockRepository();
var testMock = mocks.StrictMock<ITesting>();
Expect.Call(testMock.Test).Return("testing");
mocks.ReplayAll();
Assert.AreEqual("testing", testMock.Test);
}
}
}
However, trying to do the same thing in VB.NET won’t even compile!
Imports NUnit.Framework
Imports Rhino.Mocks
Public Interface ITesting
ReadOnly Property Test() As String
End Interface
<TestFixture()> _
Public Class MocksTest
<Test()> _
Public Sub TestMockExpect()
Dim mocks = New MockRepository
Dim testMock = mocks.StrictMock(Of ITesting)()
Expect.Call(testMock.Test).Return("testing")
mocks.ReplayAll()
Assert.AreEqual("testing", testMock.Test)
End Sub
End Class
The Expect.Call line produces the following build error: “Overload resolution failed because no accessible ‘Expect’ accepts this number of arguments.”
What is the proper way to use Expect.Call with a mocked property in VB.NET? I’ve seen a couple posts that say Rhino Mocks works better in VB10, but I’m stuck with Visual Studio 2008 for this current project.
Try
Source