views:

284

answers:

4

I am aware of Castle's DynamicProxy and RhinoMocks, but I was wondering if, given the fact that Microsoft has introduced unit testing as a first class feature of Visual Studio, whether they have provided any standardized object mocking mechanism to accompany it?

+1  A: 

Microsoft, at this point in time, doesn't provide their own mocking framework, and still refer to third party tools.

You can see this, even if you look through things like their official SharePoint Guidance, where they say:

"There are a variety of tools available that support unit testing with mock objects. The Training Management application uses a commercially available testing tool named Typemock Isolator that is provided by Typemock. You must install this tool if you want to run the unit tests."

If you search MSDN, there are many articles about testing frameworks. The most common references seem to be RhinoMocks, NMock, and Typemock.

Reed Copsey
Cheers, I've bitten the bullet and am forcing myself to learn Rhino Mocks.
Nathan Ridley
+4  A: 

I too thought that Rhino was the way to go, but after working with it for 2 months, switched to Moq.

I would highly recommend Moq if you're working with .Net 3.5. Please look at this post for some more information regarding the mocking frameworks that you are considering.

womp
Love moq for 3.5 dev!
Terry Donaghe
Moq was the first "killer app" of lambda expressions that I used.
Cogwheel - Matthew Orlando
A: 

If you are going to do unit testing, Typemock Isolator is the only tool that can currently mock SharePoint objects. Moq and Rhino cannot create SharePoint objects with internal constructor, so you'll need to work hard to fit your code for them.

Good thing I don't use Sharepoint then (and never have and never will) ;)
Nathan Ridley
+2  A: 

IMHO Rhino Mock is overly complicated due to many layers of extra features added to it over time.

Moq has most of same features that Rhino Mock but is designed from scratch and therefore provides much cleaner API. Moq misses a few features, most importantly the ability to assert exact sequence of mocked methods invoked.

I still find myself using Rhino Mock though, I guess at this point it's just a bad habit. I do recommend using Moq for all new projects though.

zvolkov