- Right-click the References node of your test class -- the context menu appears
- In the context menu, click "Add Moles Assembly for mscorlib"
- Build the project/solution
- Add a using declaration for the System.Moles assembly:
using System.Moles;
Your test project is now ready to detour members of the .NET Framework System assembly. To follow the example, above, the StringComparer method may be detoured, using the following code. (This particular detour always returns 0, which indicates both string representations of the objects are equal.)
System.Moles.MStringComparer.AllInstances.CompareObjectObject = (instance, lhs, rhs) => 0;
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.