Writing Unit Test for methods that use User.Identity.Name in ASP.NET Web API

后端 未结 8 633
醉梦人生
醉梦人生 2020-12-29 18:33

I am writing test cases using the Unit Test for ASP.NET Web API.

Now I have an action which makes a call to some method I have defined in the service layer, where I

8条回答
  •  别那么骄傲
    2020-12-29 19:07

    None of this ended up working for me, I used the solution on another question which uses Moq to set up a user name in the ControllerContext: https://stackoverflow.com/a/6752924/347455

提交回复
热议问题