0
在我的应用程序用户通过WIF登录。用户的凭证存储在System.Security.Principal.IIdentity
中。现在我想测试CreateUser()
方法。 我必须以某种方式伪造该物体。我尝试做这样的事情: 它返回一个对象-extract方法:如何使用FakeItEasy伪造System.Security.Principal.IIdentity?
public IIdentity GetIdentity()
{
return Thread.CurrentPrincipal.Identity;
}
,然后在测试文件做这样的事情:
var identity = new GenericIdentity("[email protected]");
A.CallTo(() => _userRepository.GetIdentity()).Returns(identity);
但它不工作。任何想法如何以最好的方式做到这一点?