Posts

Showing posts from February, 2013

Unit Testing SharePoint projects with Microsoft Moles

Image
SharePoint is very powerful development platform, but it’s hard to test your code without changing it. It widely uses sealed classes, non-virtual and static methods and static properties, which make it impossible to mock its objects via popular free mocking frameworks: Rhino Mocks , Moq or NMock . However there is one free framework exists on the market. It’s called Microsoft Moles Isolation Framework and it can be plugged into Visual Studio 2008/2010 Professional Edition. To use Moles we need: 1) Download Moles x86 or x64 edition 2) Install it 3) Open your test project in Visual Studio 4) Add reference to Microsoft SharePoint library (and/or any other library you need) into your project 5) Select Microsoft.SharePoint in references list, open context menu and choose “Add Moles Assembly” After this step a new file Microsoft.SharePoint.moles will be added to the project. 6) Run Build command of the project. After build we should see new references added to the project: