コード例 #1
0
ファイル: SearchController.cs プロジェクト: JobiJoba/Habitat
 public ActionResult PagedSearchResults(string query, int? page)
 {
     var pagingSettings =  this.renderingPropertiesRepository.Get<PagingSettings>();
       var pageNumber = page ?? 1;
       var results = this.GetSearchResults(new SearchQuery { Query = query, Page = pageNumber, ResultsOnPage = pagingSettings.ResultsOnPage });
       var pageble = new PagedSearchResults(pageNumber, results.TotalNumberOfResults, pagingSettings.PagesToShow, pagingSettings.ResultsOnPage);
       pageble.Query = query;
       pageble.Results = results;
       return this.View(pageble);
 }
コード例 #2
0
 public void ShouldCalculateTotalPages(int page, int totalResults, int pagesToShow, int resultsOnPage)
 {
     var searchResults = new PagedSearchResults(page, totalResults, pagesToShow, resultsOnPage);
       var totalPages = Math.Ceiling(totalResults / (double)resultsOnPage);
       searchResults.TotalPagesCount.ShouldBeEquivalentTo(totalPages);
 }
コード例 #3
0
 public void LastPageShouldNotBeGreaterThanTotalPages(int page, int totalResults, int pagesToShow, int resultsOnPage)
 {
     var searchResults = new PagedSearchResults(page, totalResults, pagesToShow, resultsOnPage);
       searchResults.FirstPage.Should().BeLessOrEqualTo(searchResults.TotalPagesCount);
 }
コード例 #4
0
 public void LastPageEdgeCase(int page, int totalResults, int pagesToShow, int resultsOnPage)
 {
     page = 1;
       var searchResults = new PagedSearchResults(page, totalResults, pagesToShow, resultsOnPage);
       searchResults.LastPage.Should().BeOneOf(pagesToShow, searchResults.TotalPagesCount);
 }
コード例 #5
0
 public void FirstPageShouldBeLessThanLast(int page, int totalResults, int pagesToShow, int resultsOnPage)
 {
     var searchResults = new PagedSearchResults(page, totalResults, pagesToShow, resultsOnPage);
       searchResults.FirstPage.Should().BeLessOrEqualTo(searchResults.LastPage);
 }
コード例 #6
0
 public void FirstPageShouldBeGreaterThanZero(int page, int totalResults, int pagesToShow, int resultsOnPage)
 {
     var searchResults = new PagedSearchResults(page, totalResults, pagesToShow, resultsOnPage);
       searchResults.FirstPage.Should().BeGreaterThan(0);
 }