public void PrintTotalWinner_Success()
        {
            EngineTermWinner totalWinner       = GetTotalWinnerMockData();
            string           totalWinnerReport = _reportManager.PrintTotalWinner(totalWinner);

            Assert.IsNotNull(totalWinnerReport);
            Assert.IsNotEmpty(totalWinnerReport);
        }
Пример #2
0
        public void GetTotalWinner_Success()
        {
            EngineTermWinner totalWinner = _winnerManager.GetTotalWinner(GetContainerSearchMockData());

            Assert.IsNotNull(totalWinner);
            Assert.IsNotEmpty(totalWinner.EngineName);
            Assert.IsNotEmpty(totalWinner.Term);

            Assert.AreEqual("Aol", totalWinner.EngineName);
            Assert.AreEqual("java script", totalWinner.Term);
        }
        public string PrintTotalWinner(EngineTermWinner totalWinner)
        {
            if (totalWinner == null)
            {
                throw new ArgumentException("The parameter is invalid", nameof(totalWinner));
            }

            StringBuilder totalWinnerBuilder = new StringBuilder();

            totalWinnerBuilder.Append(TOTAL_WINNER_MESSAGE);
            totalWinnerBuilder.Append(totalWinner.Term);

            return(totalWinnerBuilder.ToString());
        }
Пример #4
0
        public static async Task StartAsync(IList <string> terms)
        {
            ContainerSearch searchDataContainer = await SearchManager.GetSearchEngineResults(terms);

            Reports.AddRange(ReportManager.PrintSearchResults(searchDataContainer));

            List <EngineTermWinner> SearchEngineWinners = WinnerManager.GetEngineWinners(searchDataContainer);

            Reports.AddRange(ReportManager.PrintWinners(SearchEngineWinners));

            EngineTermWinner totalwinner = WinnerManager.GetTotalWinner(searchDataContainer);

            Reports.Add(ReportManager.PrintTotalWinner(totalwinner));
        }
Пример #5
0
        private List <EngineTermWinner> ParseToEngineWinners(List <Search> searchWinners)
        {
            if (searchWinners == null || searchWinners.Count == 0)
            {
                throw new ArgumentException("Invalid arguments", nameof(searchWinners));
            }

            List <EngineTermWinner> engineTermWinners = new List <EngineTermWinner>();

            foreach (Search searchWinner in searchWinners)
            {
                EngineTermWinner engineTermWinner = new EngineTermWinner
                {
                    EngineName = searchWinner.EngineName,
                    Term       = searchWinner.Term
                };

                engineTermWinners.Add(engineTermWinner);
            }

            return(engineTermWinners);
        }
Пример #6
0
        public EngineTermWinner GetTotalWinner(ContainerSearch containerSearch)
        {
            if (containerSearch == null || containerSearch.termDictionary.Count == 0)
            {
                throw new ArgumentException("Invalid arguments", nameof(containerSearch));
            }

            // get the winner list
            List <Search> winners = GetSearchWinners(containerSearch);

            // set the first winner as a Total Winner
            Search tempTotalWinner = winners.First();

            // start iterating at position 1, for position 0 is the
            // tempTotalWinner
            for (int i = 1; i < winners.Count; i++)
            {
                long winnerTotalResults     = winners.ElementAt(i).TotalQueryResults;
                long tempWinnerTotalResults = tempTotalWinner.TotalQueryResults;

                // update total winner
                if (winnerTotalResults > tempWinnerTotalResults)
                {
                    tempTotalWinner = winners.ElementAt(i);
                }
            }

            // set the engine term winner with the data of the total Winner
            EngineTermWinner engineTermWinner = new EngineTermWinner
            {
                EngineName = tempTotalWinner.EngineName,
                Term       = tempTotalWinner.Term
            };

            return(engineTermWinner);
        }
        public void PrintTotalWinner_Null_ArgumentException()
        {
            EngineTermWinner totalWinner = null;

            Assert.Throws <ArgumentException>(() => _reportManager.PrintTotalWinner(totalWinner));
        }