public void TestFixtureSetup() { PageRequester pageRequster = new PageRequester(new CrawlConfiguration { UserAgentString = "aaa" }); _goodPageResult = pageRequster.MakeRequest(new Uri("http://localhost.fiddler:1111/")); _badPageResult = pageRequster.MakeRequest(new Uri("http://localhost.fiddler:1111/HttpResponse/Status404")); }
public void SetUp() { PageRequester pageRequster = new PageRequester(new CrawlConfiguration { UserAgentString = "aaa" }); _goodPageResult = pageRequster.MakeRequest(new Uri("http://localhost.fiddler:1111/")); _badPageResult = pageRequster.MakeRequest(new Uri("http://localhost.fiddler:1111/HttpResponse/Status404")); _fakePageRequester = new Mock <IPageRequester>(); _uut = new RobotsDotTextFinder(_fakePageRequester.Object); }
public void MakeRequest_200_ReturnsValidResponse() { CrawledPage result = _unitUnderTest.MakeRequest(_validUri); Assert.IsNotNull(result); Assert.IsNotNull(result.HttpWebRequest); Assert.IsNotNull(result.HttpWebResponse); Assert.IsNull(result.WebException); Assert.IsFalse(string.IsNullOrWhiteSpace(result.Content.Text)); Assert.IsNotNull(result.HtmlDocument); Assert.IsNotNull(result.CsQueryDocument); Assert.AreEqual(200, (int)result.HttpWebResponse.StatusCode); Assert.AreEqual(938, result.Content.Bytes.Length); }
public void MakeRequest_200_ReturnsValidResponse() { CrawledPage result = _unitUnderTest.MakeRequest(_validUri); Assert.IsNotNull(result); Assert.IsNotNull(result.HttpWebRequest); Assert.IsNotNull(result.HttpWebResponse); Assert.IsNull(result.WebException); Assert.IsFalse(string.IsNullOrWhiteSpace(result.Content.Text)); Assert.IsNotNull(result.HtmlDocument); Assert.AreEqual(200, (int)result.HttpWebResponse.StatusCode); Assert.IsTrue(result.Content.Bytes.Length > 900 && result.Content.Bytes.Length < 1300); DateTime fiveSecsAgo = DateTime.Now.AddSeconds(-5); Assert.IsTrue(fiveSecsAgo < result.RequestStarted); Assert.IsTrue(fiveSecsAgo < result.RequestCompleted); Assert.IsNotNull(result.DownloadContentStarted); Assert.IsNotNull(result.DownloadContentCompleted); Assert.IsTrue(fiveSecsAgo < result.DownloadContentStarted); Assert.IsTrue(fiveSecsAgo < result.DownloadContentCompleted); }