Moq in VB.Net - any examples?

1,190 views
Skip to first unread message

TheMightyKumquat

unread,
Aug 5, 2009, 10:20:19 PM8/5/09
to Moq Discussions
Hi. New to Moq and, unfortunately, I'm having to write all my tests in
VB.Net. To make matters worse, I'm new to Lamda in both C# and VB.Net.
It might not be too bad if I was learning Moq and coding in C#, but
I'm finding it truly painful to set up even the simplest of tests with
Moq in VB.Net. Are there any examples out there in VB.Net? Surely the
entire framework can't have been developed ignoring VB.Net....

Just knowing what the VB.Net version of the syntax for the following
would help a lot.

var mock = new Mock<IFoo>

// method returning a value
mock.Setup(x => x.GetWord("xxxWord...").Returns("Word");

// void method
mock.Setup(x => x.DoSomething());

// get on property
mock.Setup(foo => foo.Name).Returns("bar");

// set on property
mock.SetupSet(foo => foo.Name = "foo");

andreister

unread,
Aug 6, 2009, 3:49:02 AM8/6/09
to Moq Discussions
Well, currently you can't moq much with VB.NET. It just doesn't
support multi statement or void returning
lambdas (although you can use the AddressOf with a normal delegate).

I tried to set up VB.NET samples in mocking-frameworks-compare project
( http://code.google.com/p/mocking-frameworks-compare/ ) but didn't
get anywhere so I gave up until VB10 is out.

In VB10 all that lambda things should be available.
Reply all
Reply to author
Forward
0 new messages