Exemple #1
0
 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);
 }
 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);
 }
 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);
 }
 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);
 }
 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);
 }
 public void FirstPageShouldBeGreaterThanZero(int page, int totalResults, int pagesToShow, int resultsOnPage)
 {
     var searchResults = new PagedSearchResults(page, totalResults, pagesToShow, resultsOnPage);
       searchResults.FirstPage.Should().BeGreaterThan(0);
 }