public void TestInit() { IHtmlWebWrapper htmlWeb = Substitute.For <IHtmlWebWrapper>(); htmlWeb.Load(Arg.Any <Uri>()).Returns(_expectedContent); _pageProvider = new PageProvider(htmlWeb); }
public void GetPageContent_NullOrEmptyPageContent_ReturnEmptyDictionary(string pageContent) { IHtmlWebWrapper htmlWeb = Substitute.For <IHtmlWebWrapper>(); KeywordsFinder keyworsdFinder = new KeywordsFinder(htmlWeb); var result = keyworsdFinder.FindKeywords(pageContent); result.Should().BeEmpty(); }
public void GetPageContent_KeywordsNotExist_ReturnEmptyDictionary(string keywords) { IHtmlWebWrapper htmlWeb = Substitute.For <IHtmlWebWrapper>(); htmlWeb.SelectNodeAttribute(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()).Returns(keywords); KeywordsFinder keyworsdFinder = new KeywordsFinder(htmlWeb); var result = keyworsdFinder.FindKeywords("Test"); result.Should().BeEmpty(); }
public void Init() { _htmlWrapper = MockRepository.GenerateMock<IHtmlWebWrapper>(); _log = MockRepository.GenerateMock<ILog>(); _extractionArgs = MockRepository.GenerateMock<IExtractionArguments>(); _extractionResults = MockRepository.GenerateMock<IExtractionResults>(); _pageScraper = MockRepository.GenerateMock<IAutoTraderZaPageScraper>(); _pageScraper.Stub(p => p.Scrape(Arg<IExtractionArguments>.Is.Anything, Arg<HtmlDocument>.Is.Anything)).Return(new List<IVehicle>()); _extractionResults.Stub(p => p.Vehicles).Return(new List<IVehicle>()); _dummyUri = new Uri("http://dummyUrl.com"); _dummyFirstDocument = new HtmlDocument(); _extractorEngine = new AutoTraderExtractionEngine(_htmlWrapper, _log, _pageScraper); }
public void GetPageContent_KeywordsAndBodyExist_ReturnProperDictionary() { IHtmlWebWrapper htmlWeb = Substitute.For <IHtmlWebWrapper>(); htmlWeb.SelectNode(Arg.Any <string>(), Arg.Any <string>()).Returns("keywrod keyword1 keyword2 keyword keyword2"); htmlWeb.SelectNodeAttribute(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()).Returns("keyword1, keyword2, keyword1"); KeywordsFinder keyworsdFinder = new KeywordsFinder(htmlWeb); var result = keyworsdFinder.FindKeywords("Test"); result.Should().BeEquivalentTo(new Dictionary <string, int> { { "keyword2", 2 }, { "keyword1", 1 }, }); }
private static void Init() { log4net.Config.XmlConfigurator.Configure(); _log = LogManager.GetLogger(typeof(Program)); _htmlWebWrapper = new HtmlWebWrapper(_log); _japaneseHtmlWebWrapper = new HtmlWebWrapper(_log, System.Text.Encoding.GetEncoding("EUC-JP")); var sqlPath = Path.GetFullPath(@"..\..\..\VehicleStatsData\SQLDatabase.mdf"); _sqlExtractRepository = RepositoryFactory.GetRepository("SqlExtractRepository", new object[] { _log, @"Data Source=(LocalDB)\v11.0;AttachDbFilename=" + sqlPath + ";Integrated Security=True" }); //_fileStatsRepository = RepositoryFactory.GetRepository("FileExtractRepository", new object[] { _log, outputPath }); //_argBuilder = new AutoTraderArgumentBuilder(_htmlWebWrapper, _log); _gooNetArgBuilder = new GooNetArgumentBuilder(_japaneseHtmlWebWrapper, _log); _autoTraderScraper = new AutoTraderZaPageScraper(_log); _gooNetPageScraper = new GooNetPageScraper(); }
public AutoTraderArgumentBuilder(IHtmlWebWrapper htmlWebWrapper, ILog log) { _htmlWebWrapper = htmlWebWrapper; _log = log; }
public GooNetArgumentBuilder(IHtmlWebWrapper htmlWebWrapper, ILog log) { _log = log; _htmlWebWrapper = htmlWebWrapper; }
public PageProvider(IHtmlWebWrapper htmlWeb) { _htmlWeb = htmlWeb ?? throw new ArgumentNullException(nameof(htmlWeb)); }
public KeywordsFinder(IHtmlWebWrapper htmlWeb) { _htmlWeb = htmlWeb ?? throw new ArgumentNullException(nameof(htmlWeb)); }
public RbnorwayScraper(IHtmlWebWrapper htmlWeb) { _htmlWeb = htmlWeb; }
public AutoTraderExtractionEngine(IHtmlWebWrapper htmlWebWrapper, ILog log, IAutoTraderZaPageScraper pageScraper) { _log = log; _htmlWebWrapper = htmlWebWrapper; _pageScraper = pageScraper; }