I’ve been interesting in unit testing for some years now. One major aspect of unit testing is about how use designs that allows a separation of concerns so you can test your program as units (usually at class level), for this the interface basic programming is a MUST.

Once you start with interfaces, you will follow with mocks, and stubs. However, this approach has a big limitation when you want to test code that depends on static methods, typical examples are ASP.Net context or SharePoint API.

The next step forward to alleviate this limitation will be the Mole pattern where using the instrumentation capabilities of the .Net runtime we are able to “inject” code that simulate static behavior without needing an explicit interface to decouple classes.

Microsoft research is working on something called Moles, that integrated with Pex will offer a brand new way to perform unit tests.

More info: http://research.microsoft.com/en-us/projects/stubs/