public async Task BingSearchScraper_BadSearch_ReturnsEmptyList() { // ASSERT: // Scraper is able to handle responses with no search results. _downloadService .DownloadWebsitesParallelAsync(urls: Arg.Any <IEnumerable <string> >()) .Returns(new List <string> { notFoundTestHtml }); var SUT = new BingSearchScraper(downloadService: _downloadService); var keyWords = new string[] { "KEYWORD1", "KEYWORD2" }; var maxSearchResults = 100; var searchResults = await SUT.Search(keyWords, maxSearchResults) as List <string>; Assert.NotNull(searchResults); Assert.False(searchResults.Any()); }
public async Task BingSearchScraper_Search_ReturnsValidSearchResults() { // ASSERT: // Scraper is able to process multiple search downloads. // One of the results contains expected substring. _downloadService .DownloadWebsitesParallelAsync(urls: Arg.Any <IEnumerable <string> >()) .Returns(new List <string> { testHtml, testHtml, testHtml }); var SUT = new BingSearchScraper(downloadService: _downloadService); var keyWords = new string[] { "KEYWORD1", "KEYWORD2" }; var maxSearchResults = 100; var expectedSubstring = "www.sympli.com.au"; var searchResults = await SUT.Search(keyWords, maxSearchResults) as List <string>; Assert.NotNull(searchResults); Assert.True(searchResults.Any(r => r.Contains(expectedSubstring))); }