Tuesday, June 23, 2009

To Mock-You or to Moq?

Recently I have been introduced to a mocking framework build specifically for .net 3.5 and C# 3.0. This framework is called Moq. More information, downloads and documentation can be found @ http://code.google.com/p/moq/

As a brief introduction, Moq is simple. That is all their is to it. The complexity of record and replay has been completely removed from the framework, well actually it was never introduced. We all know how annoying it was to learn the syntax of record and replay, and even once you understood it, really you still didn't.

Moq takes advantage of LINQ and Lambda expressions to do all the work. Here is an example of a simple person presenter test:



Moq makes learning and using mocking simple.