我的代碼做這個我怎麼能嘲笑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