0

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.

RSM
  • 14,540
  • 34
  • 97
  • 144

1 Answers1

1

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).

Dror Helper
  • 30,292
  • 15
  • 80
  • 129
  • Thanks for the answer, what about the Fakes Framework, Rhino Mocks, and Moq, would it be the same instance that they use inheritance and would need to refactor all legacy code to work with it? – RSM Jan 21 '16 at 12:15
  • Fakes has Shivs which use the profiler API as well as the twi tools I recommended but I wouldn't use it since it's unreadable and would stop compiling with trivial code refactroing. All the rest use the same method (inheritance) ad wouldn't work for you – Dror Helper Jan 21 '16 at 12:22