public void CanGetSearchResults_100Results()
        {
            //arrange
            var input = File.ReadAllText("input_100results.txt");
            var sut   = new ResultsScraper(input);
            //act
            var searchResults = sut.GetSearchResults();

            //assert

            Assert.IsTrue(searchResults.Count == 100);
        }
        public void CanGetSearchResults_2Results()
        {
            //arrange
            var input = File.ReadAllText("input_2results.txt");
            var sut   = new ResultsScraper(input);
            //act
            var searchResults = sut.GetSearchResults();

            //assert

            Assert.IsTrue(searchResults.Count == 2 &&
                          searchResults.ToArray()[0] == "https://services.dps.ohio.gov/bmvonlineservices/search/title" &&
                          searchResults.ToArray()[1] == "https://www.propertyshark.com/info/property-title-search/");
        }
        public JsonResult GetSearchResults(string[] term, string url)
        {
            var searchResult = _resultsFetcher.Fetch(term);
            var scraper      = new ResultsScraper(searchResult);
            var scraped      = scraper.GetSearchResults();

            var list = scraped
                       .AsEnumerable()
                       .Select((item, index) => new ResultViewModel()
            {
                Rank       = index + 1,
                Url        = item,
                Match      = !string.IsNullOrWhiteSpace(url) && item.Contains(url),
                MatchClass = !string.IsNullOrWhiteSpace(url) && item.Contains(url) ? "success" : "primary"
            });
            var viewModel = new ResultsListViewModel()
            {
                Summary = list.Count(x => x.Match) == 0 ? "none" : string.Join(",", list.Where(x => x.Match).Select(x => x.Rank)),
                Results = list
            };

            return(Json(viewModel, JsonRequestBehavior.AllowGet));
        }