public void GetUrlsFromGoogleSearchTest() { // Arrange Mock <IBrowserService> browserServiceMock = new Mock <IBrowserService>(); browserServiceMock.Setup(bs => bs.ScrapeTextInCiteTags()) .Returns(citeTextExample); GoogleSearchService googleSearchService = new GoogleSearchService(browserServiceMock.Object); var keywords = "test"; // Act var urlResults = googleSearchService.GetUrlsFromGoogleSearch(keywords); // Assert CollectionAssert.AreEqual(expectedUrlsExample, urlResults); }
public void GetUrlsFromGoogleSearch_WhenBrowserServiceThrowsAnException_ShouldReturnEmptyList() { // Arrange Mock <IBrowserService> browserServiceMock = new Mock <IBrowserService>(); string url = "www.whatever.com"; browserServiceMock.Setup(bs => bs.NavigateToUrl(url)) .Throws(new System.Exception()); GoogleSearchService googleSearchService = new GoogleSearchService(browserServiceMock.Object); // Act var keywords = "test"; var urlResults = googleSearchService.GetUrlsFromGoogleSearch(keywords); // Assert var expectedUrls = new List <string>(); CollectionAssert.AreEqual(expectedUrls, urlResults); Assert.AreEqual(0, urlResults.Count); }