public async Task GetPageRanks_IfResultTextIsPresentBeyondMaxResultsToSearch_ShouldNotReturnThatPageRank( string searchText, string expectedText, string searchPageUrl) { var htmlReaderMock = new Mock <IHtmlPageParser>(); var searchStrategyMock = new Mock <ISearchStrategy>(); string nullString = null; int maxResultsToSearch = 2; var urlList = new List <string> { "randomurl", expectedText, "randomurl", expectedText }; searchStrategyMock.Setup(m => m.GetSearchPageUrl(1)).Returns(searchPageUrl); searchStrategyMock.Setup(m => m.GetSearchPageUrl(2)).Returns(nullString); htmlReaderMock.Setup(m => m.GetAttributeValues(searchPageUrl, It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(urlList); var sut = new HtmlSearchResultParser(htmlReaderMock.Object); sut.SetStrategy(searchStrategyMock.Object); var result = await sut.GetPageRanks(searchText, expectedText, maxResultsToSearch); Assert.Equal(2, result.First()); Assert.Single(result); }
public async Task GetPageRanks_IfMaxResultsToSearchIsZero_ShouldReturnEmptyList(string searchText, string expectedText) { var htmlReaderMock = new Mock <IHtmlPageParser>(); var searchStrategyMock = new Mock <ISearchStrategy>(); string nullString = null; searchStrategyMock.Setup(m => m.GetSearchPageUrl(It.IsAny <int>())).Returns(nullString); var sut = new HtmlSearchResultParser(htmlReaderMock.Object); sut.SetStrategy(searchStrategyMock.Object); var result = await sut.GetPageRanks(searchText, expectedText, 0); Assert.Empty(result); }