Mock Objects in .Net… Again

About a year ago I was looking for a .Net mock object library to use in a project I was about to start, a project where we were planning to use unit testing intensively. Back then I found a couple of small but interesting projects, although none supported .Net 2.0: DotNetMock (the one we end up using) and NMock. Both of them use the same simple approach called dynamic mocks: a dynamic proxy is created from an existing interface (which is good, as it enforces “interface driven” programming), a proxy that allows the definition of expectations for that mock, which are supposed to simulate the behavior of the real object.

But recently we’ve been facing the limitations of DotNetMock, the project has been inactive for a while, which means still no support for .Net 2.0 that lead to “small” issues like no unit testing with things like Generics. That’s why I’ve been seriously considering moving to another mock object library, although it’s something that’s been postponed again and again in the last few months.

Fortunately Paulo has shown me Rhino Mocks (more than once, I admit) and what seemed, in a first glance, a open source implementation of TypeMock had a neat trick of it’s own: the ability to define expectations using objects, unlike all the others I’ve seen where you must a use a string with the method’s name (which very error prone when refactoring). Must take some time to check this one more deeply.

Oh! I almost forgot, and it supports Generics, Nullable Types and all those .Net 2.0 little things…

Technorati Tags: , , , ,


share it
  • email
  • del.icio.us
  • Facebook
  • Twitter
  • FriendFeed
  • Digg
  • Do Melhor!
  • DotNetKicks
  • DZone
  • StumbleUpon
  • Tumblr
  • Posterous

Tags: ,

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a comment