No? Nor me. (If you are wondering what Mocking is, check out my previous post on Mocking, Stubs and Test Doubles.)
I am at TechEd Europe this week in Berlin, speaking on Entity Framework 4.0 and manning the .NET Framework stand. Behind the .NET Framework stand is the Pex and Code Contracts stand manned by the two lead developers of Pex, Peli de Halleux and Nikolai Tillmann. I looked at Pex many months back but was completely unaware of a great new feature they added in September 2009 – Stubs and Moles. Peli and Nikolai kindly took me through the new features in Pex and also recorded a short podcast which I hope to get published asap on our UK MSDN Podcast on channel9.
Stubs and Moles in Pex gives us:
- The ability to mock using freely available Microsoft tools. Nice.
- The ability to mock any .NET method (including static methods). Very, very nice!
The ability to mock any .NET method (i.e. methods you don’t have source code for) is something that few mocking tools can do on the .NET platform. Actually I know of no free tools that do it (please let me know if there are some) and instead I always point people at the commercial tool TypeMock if they need that level of functionality.
Moles in action
This example shows a typical use of moles where we detour the DateTime.Now property getter to our custom delegate.
The Pex Download works with both Visual Studio 2008 and Visual Studio 2010 Beta 2.
As a reminder, Pex is an incubation project for Visual Studio, developed by Microsoft Research, and currently available via http://msdn.microsoft.com/devlabs