我正在努力分离以下代码中的依赖项:
public static SiteConnector ConnectToSite(String Logon, String Password)
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(_URI);
ConfigureRequest(Logon, Password, webRequest);
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
Cookie ReposonseCookie;
//this looks for a cookie and spitsout a value based on response
int value = ProcessResponse(webResponse,out ReposonseCookie);
return new SiteConnector(ReposonseCookie, value);
}
本质上,我想在不依赖外部网站请求的情况下进行单元测试。
解决这个问题的最佳方法是什么?