测试 MVC 之 Mock HttpContext
摘要:在 Web 中进行测试驱动的开发,比较大的困难是模拟 HttpContext ,它太复杂了。moq 框架提供了强大的模拟能力,但是,模拟一个 HttpContext 对象还是需要自己来动手。为此,我自己写了一个方法来完成这个工作。其中,还顺便使用 Log4Net 来输出一下它的工作情况。/// <summary>/// 创建上下文模拟对象 /// 至少需要支持/// Request 中/// AppRelativeCurrentExecutionFilePath,/// ApplicationPath/// PathInfo/// Response 中/// ApplyAppPat
阅读全文
posted @ 2011-07-24 20:21