我有一个接受DotNetOpenAuth(正式称为 DotNetOpenId)Response
对象的方法。我的方法提取任何声明的数据,检查该用户是否存在于我们的系统中,yadda yadda yadda... 完成后返回经过身份验证的用户实例。
现在..我如何使用moq来模拟这个响应对象,以测试我的身份验证方法(AuthenticateUser()
)?
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
User user = null;
try
{
// Extract the claimed information and
// check if this user is valid, etc.
// Any errors with be thrown as Authentication Errors.
user = _authenticationService.AuthenticateUser(response) as User;
}
catch (AuthenticationException exception)
{
ViewData.ModelState.AddModelError("AuthenticationError", exception);
}
.. other code, like forms auth, other response.status' etc. ..
}
模拟框架:moq
语言:.NET C# 3.5 sp1
响应对象:取自 DotNetOpenAuth 框架