相关疑难解决方法(0)

如何使用 Nunit 和 RhinoMocks 模拟 HttpContext.Current.GetOwinContext()?

我关于 Mocking the HttpContext 的最后一个问题相比,我不得不将正在测试的方法更改为

public override void OnActionExecuting(HttpActionContext actionContext)
{
    HttpContext.Current.GetOwinContext().Set("RequestGUID", NewId.NextGuid());
    base.OnActionExecuting(actionContext);
}
Run Code Online (Sandbox Code Playgroud)

现在我需要弄清楚如何模拟 HttpContext.Current.GetOwinContext(),所以我可以为该Set()方法编写一个存根,或者通常能够测试这个特定的行。我怎样才能做到这一点?

c# unit-testing rhino-mocks mocking owin

5
推荐指数
1
解决办法
1793
查看次数

标签 统计

c# ×1

mocking ×1

owin ×1

rhino-mocks ×1

unit-testing ×1