Compare() публичный Метод

Compares the specified pages and returns an object detailing the differences.
public Compare ( Scrape pageA, Scrape pageB ) : Comparison
pageA QualityBot.ScrapePocos.Scrape The first page.
pageB QualityBot.ScrapePocos.Scrape The second page.
Результат QualityBot.ComparePocos.Comparison
Пример #1
0
        //[Test]
        public void CanPersistComparison()
        {
            //Arrange
            var qbService = new Service();
            var myScrapeA = qbService.Scrape("www.google.com", false);
            var myScrapeB = qbService.Scrape("www.google.com", false);

            //Act
            var comparer = new Comparer();
            var myComparison = comparer.Compare(myScrapeA, myScrapeB);

            //Assert
            Assert.IsTrue(!String.IsNullOrEmpty(myComparison.Id.ToString()), "Comparison Id is Null or Empty: {0}", myComparison.Id.ToString());
        }
Пример #2
0
        public Comparison[] Compare(Request requestA, Request requestB, bool persist = true)
        {
            var scrapeA = DoScrape(requestA);
            var scrapeB = DoScrape(requestB);

            // Pass Scrapes to Comparison
            var comparer = new Comparer();
            var comparison = comparer.Compare(scrapeA, scrapeB);

            // Persist Scrapes
            SaveScrapes(persist, scrapeA, scrapeB);

            // Persist Comparison Obj
            SaveComparison(persist, comparison);

            return new[] { comparison };
        }
Пример #3
0
        //[Test]
        public void CanCompareScrapes()
        {
            //Arrange
            var tmpScraper = new Service();
            var tmpScrapeA = tmpScraper.Scrape(new Request("www.ancestry.com"));
            var tmpMongoIdA = new MongoDB.Bson.ObjectId(DateTime.Now, 0, 0, 0);
            tmpScrapeA.Id = tmpMongoIdA;

            var tmpScrapeB = tmpScraper.Scrape(new Request("www.ancestrystage.com"));
            var tmpMongoIdB = new MongoDB.Bson.ObjectId(DateTime.Now, 0, 0, 0);
            tmpScrapeB.Id = tmpMongoIdB;

            //Act
            var qbService = new Comparer();
            var retvalComparison = qbService.Compare(tmpScrapeA, tmpScrapeB);

            //Assert
            Assert.AreEqual(retvalComparison.Scrapes[0].IdString, tmpScrapeA.IdString, "Compare failed: Invalid ScrapeIDs Expected: {0}", tmpMongoIdA);
            Assert.AreEqual(retvalComparison.Scrapes[1].IdString, tmpScrapeB.IdString, "Compare failed: Invalid ScrapeIDs Expected: {0}", tmpMongoIdB);
        }
Пример #4
0
        public Comparison[] Compare(string urlA, string urlB, bool persist = true)
        {
            // Create Scrape(s)
            var requestA = new Request(urlA);
            var requestB = new Request(urlB);
            var scrapeA = DoScrape(requestA);
            var scrapeB = DoScrape(requestB);

            // Pass Scrape to Comparison
            var comparer = new Comparer();
            var comparison = comparer.Compare(scrapeA, scrapeB);

            // Persist Scrapes
            SaveScrapes(persist, scrapeA, scrapeB);

            // Persist Comparison Obj
            SaveComparison(persist, comparison);

            return new[] { comparison };
        }
Пример #5
0
        private Comparison Compare(Request requestA, Request requestB)
        {
            var scrapeA = Scrape(requestA);
            var scrapeB = Scrape(requestB);

            var comparer = new Comparer();
            var compareResult = comparer.Compare(scrapeA, scrapeB);

            return compareResult;
        }
Пример #6
0
 public Comparison CompareFakeScrapes(Scrape fakeScr1, Scrape fakeScr2)
 {
     var compare = new Comparer();
     Comparison comparison = compare.Compare(fakeScr1, fakeScr2);
     return comparison;
 }
Пример #7
0
        public Comparison[] CompareDynamic(dynamic requestA, dynamic requestB, bool persist = true)
        {
            var rA = new Request
            {
                BoundingRectangle = GetRectangle((string)requestA.boundingRectangle),
                Browser = requestA.browser,
                BrowserVersion = requestA.browserVersion,
                IncludeJquerySelector = requestA.includeJquerySelector,
                ExcludeJquerySelector = requestA.excludeJquerySelector,
                Script = requestA.script,
                ViewportResolution = GetSize((string)requestA.viewportResolution),
                Url = requestA.url
            };

            var rB = new Request
            {
                BoundingRectangle = GetRectangle((string)requestB.boundingRectangle),
                Browser = requestB.browser,
                BrowserVersion = requestB.browserVersion,
                IncludeJquerySelector = requestB.includeJquerySelector,
                ExcludeJquerySelector = requestB.excludeJquerySelector,
                Script = requestB.script,
                ViewportResolution = GetSize((string)requestB.viewportResolution),
                Url = requestB.url
            };

            var scrapeA = DoScrape(rA);
            var scrapeB = DoScrape(rB);

            // Pass Scrapes to Comparison
            var comparer = new Comparer();
            var comparison = comparer.Compare(scrapeA, scrapeB);

            // Persist Scrapes
            SaveScrapes(persist, scrapeA, scrapeB);

            // Persist Comparison Obj
            SaveComparison(persist, comparison);

            return new[] { comparison };
        }
Пример #8
0
        public Comparison[] CompareScrapeIds(string scrapeIdA, string scrapeIdB, bool persist)
        {
            var persister = PersisterFactory.CreateScrapePersisterInstance();

            var scrapeA = persister.Load(scrapeIdA).First();
            var scrapeB = persister.Load(scrapeIdB).First();

            // Pass Scrapes to Comparison
            var comparer = new Comparer();
            var comparison = comparer.Compare(scrapeA, scrapeB);

            // Persist Comparison Obj
            SaveComparison(persist, comparison);

            return new[] { comparison };
        }