public IEnumerable <ISearchResult> Search(string search, int page) { try { //Build search url var searchUrl = searchUrlBuilder.BuildSearchUrl(search, page); //Get the plane Html result var searchHtmlResult = searchWebClient.Search(searchUrl); //Parse html and convert it to Model IEnumerable <ISearchResult> searchResults = searchParser.Parse(searchHtmlResult); SetIncrementalId(searchResults); return(searchResults); } catch (Exception ex) { return(new List <ISearchResult> { new SearchResult { Id = 1, Title = $"Error on page {page}", Summary = ex.Message } }); } }
public void BuildSearchUrl_Page1() { //Arrange var expected = "https://www.bing.com/search?q=Hello+World!&first=1"; //Act var actual = bingSearchUrlBuilder.BuildSearchUrl("Hello World!", 1); //Assert Assert.AreEqual(actual, expected); }
public IEnumerable <ISearchResult> Search(string search, int page) { //TODO: implement error handling logic //Build search url var searchUrl = searchUrlBuilder.BuildSearchUrl(search, page); //Get the plane Html result var searchHtmlResult = searchWebClient.Search(searchUrl); //Parse html and convert it to Model IEnumerable <ISearchResult> searchResults = searchParser.Parse(searchHtmlResult); SetIncrementalId(searchResults); return(searchResults); }