Geeks With Blogs

News

This blog has moved to ericnelson.wordpress.com

 Subscribe in a reader

Add to Google Reader or Homepage


Links
View my teams slideshare
These postings are provided "AS IS" with no warranties, and confer no rights.



IUpdateable has moved to ericnelson.wordpress.com Please visit http://ericnelson.wordpress.com

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

Posted on Wednesday, November 11, 2009 11:39 AM .NET 3.5 , .NET 4.0 , Project NEric | Back to top


Comments on this post: Did you know Microsoft makes a mocking tool? Meet the latest version of Pex

No comments posted yet.
Your comment:
 (will show your gravatar)
 


Copyright © Eric Nelson | Powered by: GeeksWithBlogs.net | Join free