So if you want to use TDD in .NET and use .NET types from for example mscorlib.dll, then you find your self creating interfaces for things like System.IO.File. System.DateTime etc., this is the way you do things in TDD, so the types can be mocked, but this is time consuming. To the rescue comes Microsoft Research with Moles (http://research.microsoft.com/en-us/projects/moles/).

 

This allows you to replace any .NET method with your own delegate, including non-virtual / static .NET methods in sealed types, in your test. So production code just uses the .NET types, but in your test you can mock these methods by your own implementations.

Watch the video at: http://channel9.msdn.com/blogs/peli/moles-replace-any-net-method-with-a-delegate

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.