Exemple #1
0
        public void CanClonePageListScrapper()
        {
            //Arrange
            _scrapper.ItemXPath          = "div.productList";
            _scrapper.PaginationSettings = new PageListPagination
            {
                ShowLastPagination = true,
                PaginationSelector = ".pagination"
            };
            _scrapper.Items = new List <ScrapeItemSetting>
            {
                new ScrapeItemSetting {
                    Key = "Name", Selector = ".productname"
                },
                new ScrapeItemSetting {
                    Key = "Url", Selector = ".url"
                },
            };
            var newScrapper = new PageListScrapper(_settingRepository.Object, _loggingService.Object, _webQueryService.Object);


            //Act
            _scrapper.Clone(newScrapper);
            newScrapper.ItemXPath = "div .list";
            newScrapper.PaginationSettings.ShowLastPagination = false;
            newScrapper.Items[0].Selector = "#productName";

            //Asserts
            Assert.That(newScrapper.Items.Count, Is.EqualTo(2));
            Assert.That(newScrapper.ItemXPath, Is.EqualTo("div .list"));
            Assert.That(_scrapper.Items[0].Selector, Is.EqualTo("#productName"));
            Assert.That(newScrapper.Items[0].Selector, Is.EqualTo("#productName"));
            Assert.That(_scrapper.ItemXPath, Is.EqualTo("div.productList"));
            Assert.That(newScrapper.PaginationSettings.ShowLastPagination, Is.EqualTo(false));
            Assert.That(_scrapper.PaginationSettings.ShowLastPagination, Is.EqualTo(false));
        }