Today, I happen to find an interesting post on mocking SharePoint context using TypeMock. Being a JustMocker, i thought rather to follow the footsteps and see if can do the same with JustMock. I am no SharePoint expert. Occasionally, I use a Windows 2003 VM with SharePoint server installed which gives me the required flavor of SharePoint for testing SP capabilities of JM.
Anyway, here is the original post that i am going to recycle using JustMock.
The scenario here is pretty simple. There is a method that returns an URL from the current SPContext which i am going to mock in order to return my expected URL.
Therefore, the class for which the behavior to be mocked is similar to:
Finally, the test that creates fake instance of SPSite and passes it to the current context:
I have used JustMock SP1 for the purpose and thanks to the original author for this sample.
Hope that helps
Copyright © 2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.