开发者

How to mock objects using MSTest?

I'm new with MSTest (开发者_如何学运维Visual Studio 2010). Is there any integrated mocking framework that comes with VS2010? Or is there any other good mocking framework that's easy to pick up that I could use?


The VS 2010 doesn't come with mocking framework. But you can use either Rhino Mocks (supports .NET 2.0 and 3.5), or Moq (supports .NET 3.5 and .NET 4).

Both frameworks are good, but I prefer Moq, since it feels more natural to me. It uses fluent lambda syntax which feels very clean to me once you get used to it.

Both frameworks are open source.

If you want a commercial one, go with Typemock isolator. This framework can mock virtually anything but not free.


you may want to take a look at pex and moles. I haven't really played with it but if you want to stay faithful to MS tools, take a stab at it.


Not sure if mocking supported yet by Microsoft. I used rhino mock for type safety option, you can read this just for a warm up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜