/// <summary>
        /// Action for serving the ASP.NET version of this application.
        /// </summary>
        /// <param name="searchText">The query's search text (e.g. hash tag)</param>
        /// <param name="requestedPage">The page of data requested for display</param>
        /// <returns></returns>
        public ActionResult Search(TwitterSearchModel model)
        {
            if (String.IsNullOrEmpty(model.SearchText))
            {
                return View();
            }

            PopulateSearchResultModel(model);
            return View(model);
        }
        public void Display10TweetsPerPage()
        {
            TwitterSearchController controller = GetController();
            TwitterSearchModel model = new TwitterSearchModel();
            model.SearchText = "#test";

            var result = controller.Search(model) as ViewResult;
            Assert.IsNotNull(result, "Expected a ViewResult");

            var resultModel = result.Model as TwitterSearchModel;
            Assert.IsNotNull(resultModel, "Expected a TwitterSearchModel");
            Assert.AreEqual(10, resultModel.SearchResultModel.TweetResults.Count());
        }
 private void PopulateSearchResultModel(TwitterSearchModel model)
 {
     // Retrieve data and populate the search result model for display
     model.SearchResultModel = new TwitterSearchResultModel();
     try
     {
         TwitterSearchClient searchClient = new TwitterSearchClient(
             new SessionStateCache(this.HttpContext.Session),
             new TwitterizerSearchService());
         model.SearchResultModel.TweetResults = searchClient.Search(
             model.SearchText,
             model.ClientPage,
             model.ClientPageSize,
             model.NewSearch);
     }
     catch (TwitterSearchException twitterSearchException)
     {
         model.SearchResultModel.ErrorMessage = "An error occurred when attempting to search Twitter's records, please try again later.";
     }
     catch (Exception exception)
     {
         model.SearchResultModel.ErrorMessage = "An unexpected error occurred, yikes!";
     }
 }