Guest User

Untitled

a guest
Jul 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. [Test]
  2. public void Can_View_A_Single_Page_Of_Products()
  3. {
  4. //Arrange, if there are 5 products in the repository...
  5. IProductsRepository repository = UnitTestHelpers.MockProductsRepository(
  6. new Product { Name = "P1" }, new Product { Name = "P2" }, new Product { Name = "P3" },
  7. new Product { Name = "P4" }, new Product { Name = "P5" }
  8. );
  9.  
  10. var controller = new ProductsController(repository);
  11. controller.PageSize = 3;
  12.  
  13. //Act When the user asks for the second page...
  14. var result = controller.List(null, 2);
  15.  
  16. //Assert (they'll just see the last two produdcts)
  17. var viewModel = (ProductsListViewModel)result.ViewData.Model;
  18. var displayedProducts = viewModel.Products;
  19. displayedProducts.Count.ShouldEqual(2);
  20. displayedProducts[0].Name.ShouldEqual("P4");
  21. displayedProducts[1].Name.ShouldEqual("P5");
  22. }
Add Comment
Please, Sign In to add comment