Moles – Replace any .NET method with a delegate


I just shot a short video giving a short demo of Moles, a new framework that allows replacing any .NET method with a delegate. In the context of unit testing, one can use Moles to isolate from environment dependencies (such as time, file system, database, etc…) even when those dependencies are hard-coded through static method or sealed types. In this demo, I go through the famous Y2K bug and how to test it…


https://channel9.msdn.com/posts/Peli/Moles-Replace-any-NET-method-with-a-delegate/


Moles is part of Pex: http://research.microsoft.com/en-us/projects/pex/

Comments (2)

  1. couponcode says:

    HG

  2. Larry Johnson says:

    Realize this is old and that you may have moved on, but in any case….

    I have a valid scenario for mocking a private method out of System.Data.SqlClient.SqlCommandBuilder.  This is for a utility Winform program, not real "production" code.  But it is NOT a UnitTest and as such does not have a "Mole Extension" or run in a "Instrumented Process"  —  at least I don't think so.  I really don't want to be forced to pretend this is a unittest just in order to use Moles.

    QUESTION: how can Moles be used outside of a unit test framework, but instead in a plain-ole Winforms project?

    Thanks