DotNetOpenAuth を使用する AccountController をテストしようとしていますが、問題が発生しています。Logon Actionresult をテストして、正しいビューが返されていることを確認したいと考えています。realm (私が思うに) には HttpContext.Current が null でないことを要求するコントラクトがあるため、テストは失敗します。どうにかしてリクエストをモックする必要があると思いますが、どうすればよいかわかりません。
これは ActionResult コードです。DotNetOpenAuth の例から直接取得したものです。
[AcceptVerbs(HttpVerbs.Post), ValidateAntiForgeryToken]
public ActionResult LogOn(string openid_identifier,
bool rememberMe,
string returnUrl)
{
Identifier userSuppliedIdentifier;
if (Identifier.TryParse(openid_identifier, out userSuppliedIdentifier))
{
try
{
var request = this.RelyingParty
.CreateRequest(openid_identifier,
Realm.AutoDetect,
Url.ActionFull("LogOnReturnTo"));
if (!string.IsNullOrEmpty(returnUrl))
{
request.SetUntrustedCallbackArgument("returnUrl", returnUrl);
}
return request.RedirectingResponse.AsActionResult();
}
catch (ProtocolException ex)
{
ModelState.AddModelError("OpenID", ex.Message);
}
}
else
{
ModelState.AddModelError("openid_identifier",
"This doesn't look like a valid OpenID.");
}
return RedirectToAction("LogOn", "Account");
}
前もって感謝します、
ピクルス