Exemplo n.º 1
0
        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
                    }
                });
            }
        }
Exemplo n.º 2
0
        public void ParseResultTest()
        {
            var resultString = _client.GetResultString();
            var result       = _parser.Parse(resultString);

            Assert.AreEqual("11,210,000,000", result, "Result is not being parsed correctly");
        }
Exemplo n.º 3
0
        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);
        }