我的代码做这个我怎么能嘲笑Request.Url.GetLeftPart(),所以我的单元测试通过
string domainUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
int result = string.Compare(domainUrl, "http://www.facebookmustdie.com");
// do something with the result...
我怎么能嘲笑这个,所以我的单元测试通过,我必须嘲笑整个HttpContext类?如果这是我怎么会注入到这一点的代码,这样的“正确”的HttpContext当单元测试运行
你可以嘲笑或使用存根,你必须决定你想要做什么。 – 2012-10-17 20:39:54