Interested in a
Personal Demo ?

Name* :
Please Enter your Name
Company E–Mail* :
Please Enter a Valid Email


We need to maintain legacy applications that were not built to facilitate unit testing. Without Typemock we would be completely unable to effectively test these applications. Typemock boosts productivity because you do not have to explicitly code from the ground up with testing in mind, which can be difficult to handle. Typemock has been able to cover up the coupling and dependency sins that we all have leaked into our applications from time to time.  
Edmund D. Gorski, President, CodePoets, Inc.
Edmund D. Gorski, President, CodePoets, Inc.
Success stories


US Toll Free
Outside US
Get your printable quote
Buy online


Unit Testing SharePoint Applications the easy way


“Typemock Isolator is a great way to open up the world of unit testing 
to SharePoint developers. Unit testing SharePoint applications is an 
important part of our soon to be released P&P SharePoint Guidance 
and Typemock Isolator is integral to our unit testing guidance.”
Ajoy Krishnamoorthy, Lead Product Planner for Patterns & Practices,Developer Division at Microsoft



How to unit test your SharePoint custom code by isolating the object model (SPSite)

The biggest problem with testing SharePoint code, is its dependency on the SharePoint object model. The following example shows how to easily unit test your custom code. Here's the method we want to test:

public List GetUrgentTasks()
    var site = new SPSite("");
    var taskList = site.OpenWeb().Lists[TASKS_LIST_NAME];
    var urgentTasks = new List();
    foreach (SPItem item in taskList.Items)
    return urgentTasks;


Here's how the test looks like:

public void GetAllTasks_ThreeItemsInTasksList_ThreeTaskItemsFound()
   // Recursive fake - complete SPSite object model is faked
   var fakeSite = Isolate.Fake.Instance();
   // Swap future instance of SPSite
   // Retrieve a fake SPList to set behavior
   var fakeTaskList = fakeSite.OpenWeb().Lists[TASKS_LIST_NAME];
   // Create a fake SPListItem
   var fakeItem = Isolate.Fake.Instance();
   // List collection shall return an array containing three fake items
   (new[] {fakeItem, fakeItem, fakeItem}); 
   // Call the method under test
   var urgentTasks = classUnderTest.GetAllTasks(); 
   Assert.AreEqual(3, urgentTasks.Count);


Learn more:

Articles how others are using Isolator to test SharePoint Code: