【发布时间】:2012-06-02 21:52:26
【问题描述】:
在我的应用中,用户通过 WIF 登录。用户的凭据存储在System.Security.Principal.IIdentity 中。现在我想测试CreateUser() 方法。
我必须以某种方式伪造那个对象。我尝试做这样的事情:
-返回该对象的提取方法:
public IIdentity GetIdentity()
{
return Thread.CurrentPrincipal.Identity;
}
然后在测试文件中做这样的事情:
var identity = new GenericIdentity("mymail@mydomain.com");
A.CallTo(() => _userRepository.GetIdentity()).Returns(identity);
但它不起作用。任何想法如何以最好的方式做到这一点?
【问题讨论】:
标签: asp.net asp.net-mvc-3 wif fakeiteasy