0

I'm using sharepoint 2013 and trying to unit testing for my methods. Had issues in methods having SPContext and HTTPContext but can resolve that with help of article here

Now i want to test the methods which are using SPUser, in order to achieve this i want to mock the user with my own data for example. I want the SPUser.LoginName as "test" and SPUser.Email as [email protected].

My aim is to to mock the current user in unit testing i.e, web.CurrentUser

Can anyone help on this?.

Thanks in advance..

1
  • Are you using any framework for mocking? Commented Jun 19, 2014 at 6:30

1 Answer 1

1

There is no direct way to Mock SPUser object. You can use various tools to perform unit testing for Sharepoint:

http://msdn.microsoft.com/en-in/library/ff650441.aspx

http://blog.typemock.com/2008/09/16/testing-sharepoint-now-easier-with-the-new-api

http://www.telerik.com/forums/mocking-spuser

1
  • Thanks Aanchal. I tried all these already, but i'm not able to mock SPWeb.CurrentUser. instead everytime i'm gettin the user who has logged in the server, in my case its "Administrator". Commented Jun 19, 2014 at 12:43

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.