21 October 2011

How Do I Mole .NET Framework Types?

Moles ships with pre-compiled moles assemblies for the entire .NET Framework (mscorlib).  (This used to be a huge pain to compile!)  Adding the moled mscorlib is easy.  Just follow these three steps:

  1. Right-click the test project References node, in Solution Explorer
  2. Select the "Add moles assembly for mscorlib"
  3. Compile the solution
You are now able to add using declarations for any .NET Framework type.  Do so by adding ".Moles" to the end of the desired namespace.  For example:


using System.IO.Moles;
using System.Net.NetworkInformation.Moles;

No comments:

Post a Comment

Please provide details, when posting technical comments. If you find an error in sample code or have found bad information/misinformation in a post, please e-mail me details, so I can make corrections as quickly as possible.