RhinoMocks Expect.Call syntax - not compiling in VB.Net

54 views
Skip to first unread message

TheMightyKumquat

unread,
Jul 6, 2009, 9:42:30 PM7/6/09
to Rhino.Mocks, davi...@devnet.ato.gov.au
Hi. Just getting started on RhinoMocks and I'm puzzled why I can code
this in C#, but coding it in VB.Net gives a compile error.

using (mocks.Record())
{
***** ERROR LINE ***** Expect.Call
(timeController.MyMethod(t)).Return(fakeObj);
}
using (mocks.Playback())
{
TestInt y = timeController.ReturnSame(t);
Assert.AreEqual(fakeObj, y);
}

If I code this exact statement in VB.Net, I get a compile error on the
Expect.Call line.

The message is "Overload resolution failed because no accessible
'Expect' accepts this number of arguments."

This is really causing me problems, because I don't know of any other
code that will set a return value for a method called on my mock
object. So two questions:
- why am I getting the error in VB.Net? &
- is there any alternative syntax? (Recoding the tests in C# is not an
option - company policy is to code in VB.Net)

ulu

unread,
Jul 10, 2009, 8:33:03 AM7/10/09
to Rhino.Mocks
I remember having this error, which is really weird ("Expect"
shouldn't accept any arguments, it's not a method). As far as I
remember, something with the naming conflict. You can 1) try
specifying the namespace for Expect; 2) use Option Strict, Explicit,
and stuff; 3) use LastCall instead of Expect.Call; 4) switch to AAA
(recommended).

As for the AAA syntax, it might be a problem in VB due to halfway
support of lambdas, but here's a clue:
http://blogs.lessthandot.com/index.php/DesktopDev/MSTech/vb-net-rhino-mocks-and-the-aaa-syntax-1

Have fun!

ulu
Reply all
Reply to author
Forward
0 new messages