Example #1
0
        private void crawler_PageCrawlCompleted(object sender, PageCrawlCompletedArgs e)
        {
            PageResult pageResult = new PageResult();
            pageResult.Url = e.CrawledPage.Uri.AbsoluteUri;
            if(e.CrawledPage.HttpWebResponse != null)
                pageResult.HttpStatusCode = Convert.ToInt32(e.CrawledPage.HttpWebResponse.StatusCode);

            _actualCrawledPages.Add(pageResult);
        }
Example #2
0
        private Discrepancy ReturnIfIsADiscrepency(PageResult expectedPage, PageResult actualPage)
        {
            Discrepancy discrepancy = null;
            if (expectedPage == null)
            {
                discrepancy = new Discrepancy { Actual = actualPage, Expected = null, DiscrepencyType = DiscrepencyType.UnexpectedPageInResult };
            }
            else
            {
                if (expectedPage.HttpStatusCode != actualPage.HttpStatusCode &&
                    (!IsServerUnavailable(expectedPage) &&
                    !IsServerUnavailable(actualPage)) )
                {
                    discrepancy = new Discrepancy { Actual = actualPage, Expected = expectedPage, DiscrepencyType = DiscrepencyType.UnexpectedHttpStatus };
                }

            }

            return discrepancy;
        }
Example #3
0
        private bool IsServerUnavailable(PageResult page)
        {
            bool isUnavailable = false;

            if (page.HttpStatusCode == 0 ||
                page.HttpStatusCode == 502 ||
                page.HttpStatusCode == 504)
            {
                isUnavailable = true;
            }

            return isUnavailable;
        }