Exemplo n.º 1
0
        public void BingSearch_NullQuery_ResultsCountEqualTo0()
        {
            var search    = _searchEngine.Search("");
            var listCount = search.Results.Count;

            Assert.AreEqual(0, listCount);
        }
Exemplo n.º 2
0
        public void Search_ShouldReturnSearchReturnModel_WhenGivenATerm()
        {
            var term     = "java";
            var expected = new SearchResult
            {
                EngineName   = "Bing",
                TermToSearch = term,
                Result       = 1000
            };

            var response = new BingResponseDto()
            {
                WebPages = new WebPagesDto {
                    TotalEstimatedMatches = 1000, WebSearchUrl = "http://FakeUrl"
                },
                _Type = "CustomSearch"
            };

            _gateway.Setup(g => g.SearchByExpression(It.IsAny <string>())).Returns(response);

            var actual = _searchEngine.Search(term);

            actual.Should().BeEquivalentTo(expected);
        }
Exemplo n.º 3
0
        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();
        }