Example #1
0
        private List <Discrepancy> GetDescrepancies()
        {
            List <Discrepancy> discrepancies       = new List <Discrepancy>();
            List <PageResult>  expectedCrawlResult = GetExpectedCrawlResult();

            foreach (PageResult actualPage in _actualCrawledPages)
            {
                Discrepancy discrepancy = ReturnIfIsADiscrepency(expectedCrawlResult.FirstOrDefault(p => p.Url == actualPage.Url), actualPage);
                if (discrepancy != null)
                {
                    discrepancies.Add(discrepancy);
                }
            }

            if (expectedCrawlResult.Count != _actualCrawledPages.Count)
            {
                foreach (PageResult expectedPage in expectedCrawlResult)
                {
                    PageResult expectedPageInActualResult = _actualCrawledPages.FirstOrDefault(a => a.Url == expectedPage.Url);
                    if (expectedPageInActualResult == null)
                    {
                        discrepancies.Add(new Discrepancy {
                            Actual = null, Expected = expectedPage, DiscrepencyType = DiscrepencyType.MissingPageFromResult
                        });
                    }
                }
            }

            return(discrepancies);
        }
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);
        }