public void Bing_Query_Positive() { var bingService = new BingSearchEngine(); long result = bingService.GetQueryResults(".net"); Assert.IsTrue(result > 0); }
public List <SearchResult> executeSearchs(String[] args) { var p = new Program(); List <SearchResult> list = new List <SearchResult>(); GoogleSearchEngine googleSearch = new GoogleSearchEngine(googleUrl); BingSearchEngine bingSearch = new BingSearchEngine(bingUrl); for (int i = 0; i < args.Length; i++) { SearchResult searchResult = new SearchResult(); googleSearch.configurateRequest(args[i]); googleSearch.executeReader(); bingSearch.configurateRequest(args[i]); bingSearch.addHeaders(); bingSearch.executeReader(); searchResult.word = args[i]; searchResult.resultsGoogleEngine = googleSearch.numberResults(); searchResult.resultsBingEngine = bingSearch.numberResults(); Console.WriteLine(searchResult.word + ": Google: " + searchResult.resultsGoogleEngine + " Bing: " + searchResult.resultsBingEngine); list.Add(searchResult); } return(list); }
public async Task <OperationResult <IEnumerable <ImageSearchResult> > > Search(string query, int resultsCount = 10) { var sw = Stopwatch.StartNew(); var result = new List <ImageSearchResult>(); if (WebHelper.IsStringUrl(query)) { var s = ImageHelper.ImageSearchResultForImageUrl(query); if (s != null) { result.Add(s); } } var bingResults = await BingSearchEngine.PerformImageSearch(query, resultsCount); if (bingResults != null) { result.AddRange(bingResults); } var iTunesResults = await ITunesSearchEngine.PerformImageSearch(query, resultsCount); if (iTunesResults != null) { result.AddRange(iTunesResults); } sw.Stop(); return(new OperationResult <IEnumerable <ImageSearchResult> > { IsSuccess = true, Data = result, OperationTime = sw.ElapsedMilliseconds }); }
public void Bing_QuotationMarks_Positive() { var bingService = new BingSearchEngine(); long result = bingService.GetQueryResults("\"node js\""); Assert.IsTrue(result > 0); }
public void GenerateInvalidUrlWithNullReferenceException() { var bse = new BingSearchEngine(null); var searchText = "Привет"; Assert.Throws <NullReferenceException>(() => bse.GetFormattedSearchUrl(searchText)); }
public async Task Search_Success_WithEmptyResults() { var bingSearchEngine = new BingSearchEngine( GetOptions("accessKey"), GetMockWebDataSearchWithEmptyResults()); var result = await bingSearchEngine.SearchFirst10("query"); Assert.Empty(result); }
public async Task Search_Success_With10Results() { var bingSearchEngine = new BingSearchEngine( GetOptions("accessKey"), GetMockWebDataSearchWith10Results()); var result = await bingSearchEngine.SearchFirst10("query"); Assert.Equal(FoundItemVMTestUtilities.GetTestFoundItems(count), result, new FoundItemVMComparer()); }
public async Task Search_ArgumentNullException_AccessKey(string accessKey) { var bingSearchEngine = new BingSearchEngine( GetOptions(accessKey), GetMockWebDataSearchWith10Results()); var ex = await Assert.ThrowsAsync <ArgumentNullException>(() => bingSearchEngine.SearchFirst10("query")); Assert.Equal(nameof(accessKey), ex.ParamName); }
public void ParseErrorSearchResult() { string json = File.ReadAllText("./Data/BingErrorResponse.json"); var bse = new BingSearchEngine(null); var result = bse.ParseSearchResponse(json); Assert.True(result != null && result.HasError, "JSON response not parsed"); }
public void GenerateInvalidUrlWithFormatException() { var opt = new BingSearchOption() { BaseUrl = "https://api.cognitive.microsoft.com/bing/v7.0/search?q={", Key = "key" }; var bse = new BingSearchEngine(opt); Assert.Throws <FormatException>(() => bse.GetFormattedSearchUrl(null)); }
public void GenerateValidUrl() { var opt = new BingSearchOption() { BaseUrl = "https://api.cognitive.microsoft.com/bing/v7.0/search?q={0}", Key = "key" }; var bse = new BingSearchEngine(opt); var searchText = "Привет"; var url = bse.GetFormattedSearchUrl(searchText); Assert.True(!string.IsNullOrWhiteSpace(url), "url is null or whitespace"); }
private static void PerformSearch(string param1, string param2) { try { string finalGoogleResult = string.Empty; string finalBingResult = string.Empty; var totalFinalParam1Result = 0; var totalFinalParam2Result = 0; var googleResults1 = GoogleSearchEngine.Search(param1); var bingResults1 = BingSearchEngine.Search(param1); var googleResults2 = GoogleSearchEngine.Search(param2); var bingResults2 = BingSearchEngine.Search(param2); Console.WriteLine(param1 + " : " + "Google: " + googleResults1 + " Bing: " + bingResults1); Console.WriteLine(param2 + " : " + "Google: " + googleResults2 + " Bing: " + bingResults2); //Search Engine 1 if (googleResults1 > googleResults2) { finalGoogleResult = param1; Console.WriteLine("Google Winner:" + param1); } else if (googleResults1 < googleResults2) { finalGoogleResult = param2; Console.WriteLine("Google Winner:" + param2); } //Search Engine 2 if (bingResults1 > bingResults2) { finalBingResult = param1; Console.WriteLine("Bing Winner:" + param1); } else if (bingResults1 < bingResults2) { finalBingResult = param2; Console.WriteLine("Bing Winner:" + param2); } totalFinalParam1Result = Convert.ToInt32(googleResults1) + bingResults1; totalFinalParam2Result = Convert.ToInt32(googleResults2) + bingResults2; //Total Winner if (totalFinalParam1Result > totalFinalParam2Result) { Console.WriteLine("Total Winner:" + param1); } else if (totalFinalParam1Result < totalFinalParam2Result) { Console.WriteLine("Total Winner:" + param2); } } catch (Exception ex) { LogError.AddLogError(ex.Message, ex.StackTrace); } Console.Read(); }
public BingSearchEngineTests() { _gateway = new Mock <IBingSearchEngineGateway>(); _searchEngine = new BingSearchEngine(_gateway.Object); }
public BingSearchEngineTests() { _searchEngine = new BingSearchEngine(); }
public BingSearchTest() { _bingSearchEngine = new BingSearchEngine(); }