public void EnsureThatExceptionIsThrownIfPlaceholderNotSuppliedForGetResultsInSearchEngineBase() { GoogleSearchEngine searchEngine = new GoogleSearchEngine(); string queryString = "/search?client=firefox-b-d&q=google"; List <ResultItem> results = new List <ResultItem>(); Assert.ThrowsException <FormatException>(() => results = searchEngine.GetResults(queryString, "stackoverflow.com")); }
public async Task Search_Success_WithEmptyResults() { var googleSearchEngine = new GoogleSearchEngine( GetOptions("apiKey", "cx"), GetMockWebDataSearchWithEmptyResults()); var result = await googleSearchEngine.SearchFirst10("query"); Assert.Empty(result); }
public async Task Search_ArgumentNullException_Query(string query) { var googleSearchEngine = new GoogleSearchEngine( GetOptions("apiKey", "cx"), GetMockWebDataSearchWith10Results()); var ex = await Assert.ThrowsAsync <ArgumentNullException>(() => googleSearchEngine.SearchFirst10(query)); Assert.Equal(nameof(query), ex.ParamName); }
public async Task Search_Success_With10Results() { var googleSearchEngine = new GoogleSearchEngine( GetOptions("apiKey", "cx"), GetMockWebDataSearchWith10Results()); var result = await googleSearchEngine.SearchFirst10("query"); Assert.Equal(FoundItemVMTestUtilities.GetTestFoundItems(count), result, new FoundItemVMComparer()); }
static async Task MainAsync(string[] args) { var googleSearchEngine = new GoogleSearchEngine(); var result = await googleSearchEngine.GetSearchResultCount("javascript"); Console.WriteLine($"We have found {result} results for search term 'javascript' (Google Search Engine)"); Console.ReadLine(); }
public GoogleSearchEngineTests() { _gateway = new Mock <IGoogleSearchEngineGateway>(); _searchEngine = new GoogleSearchEngine(_gateway.Object); }