Search code examples
unit-testingsharepointmockingnmock

Does NMock support SharePoint?


Does any version of NMock support mocking SharePoint?

I am using Visual Studio 2012, SharePoint 2013.

This can be any version of NMock 1, 2, or the most recent version 3.

I have tried looking at the documentation and nothing jumped out at me to say whether it does or doesnt.


Solution

  • Although I haven't used NMock in a while I find it hard to believe that it will support SharePoint . The problem with unit testing/mocking SharePoint objects is that many of them are sealed and/or do not have a public constructor.

    Since NMock uses inheritance for Mocking it could not fake objects that it cannot inherit.

    The only Mocking frameworks I know for SharePoint are Typemock's Isolator, Telerik's JustMock and perhaps MS Fakes. All uses the Profiler API to fake objects and as such can fake static, and sealed (as well as classes without public c'tors).