Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.44 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. const int pageSize = 10;
  2. var allProducts = database.Products.All(); //15 products
  3.  
  4. //products 1-10
  5. var firstPage = allProducts.ToPagedList(0, pageSize);
  6. Assert.Equal(10, firstPage.Count);
  7. Assert.False(firstPage.HasPreviousPage);
  8. Assert.True(firstPage.HasNextPage);
  9.  
  10. //products 11-15
  11. var secondPage = allProducts.ToPagedList(1, pageSize);
  12. Assert.Equal(5, secondPage.Count);
  13. Assert.False(secondPage.IsFirstPage);
  14. Assert.True(secondPage.IsLastPage);