【发布时间】:2012-05-01 17:39:04
【问题描述】:
我有方法期望 HttpContext 类型变量。
public string GetQueryStringValues(HttpContext context)
我正在从文章hanselman article 编写单元测试,使用 Moq 创建/填充 HttpContext 并按如下方式传递给方法:
string url = "http://localhost:51209/WebForm1.aspx?height=6&width=7&length=8&mode=walk";
HttpContextBase contextbase = MoqHelper.FakeHttpContext(url);
string result = new Helper(whitelist).GetQueryStringValues(context);
我收到以下错误消息:
无法从“System.Web.HttpContextBase”转换为“System.Web.HttpContext”
如何在不更改方法 GetQueryStringValues 的签名的情况下解决此问题??
请帮忙。
谢谢
【问题讨论】:
标签: c# asp.net unit-testing moq