Пример #1
0
 public ViewResult GetResults(InputFields inputFields)
 {
     if (ModelState.IsValid)
     {
         string  googleSearchUrl = UrlGenerator.GenerateGoogleSearchUrl(inputFields.KeyWords);
         string  webPageContent  = WebPageDownloader.GetWebPageContent(googleSearchUrl);
         string  rankings        = ResultsGenerator.GetRankingsFormattedAsString(webPageContent, inputFields.Url);
         Results results         = new Results {
             Rankings = rankings
         };
         return(View("Results", results));
     }
     return(View("Index"));
 }
        public void GivenKeyWordsAndMaxNumOfResultsExpectCorrectUrl()
        {
            //Arrange
            const string KeyWordsSpaceDelimited = "some key words";
            const int    MaxNumOfResults        = 20;

            //Act
            string actualUrl = UrlGenerator.GenerateGoogleSearchUrl(KeyWordsSpaceDelimited, MaxNumOfResults);

            //Assert
            const string ExpectedUrl = "https://www.google.com.au/search?q=some+key+words&num=20";

            Assert.AreEqual(actualUrl, ExpectedUrl);
        }