//удостоверяемся, что контроллер отправляет представлению правильную информацию о разбиении на страницы public void Can_Send_Pagination_View_Model() { // Организация (arrange) Mock <IBMWRepository> mock = new Mock <IBMWRepository>(); mock.Setup(m => m.BMWs).Returns(new List <BMW> { new BMW { Id = 1, Name = "Игра1" }, new BMW { Id = 2, Name = "Игра2" }, new BMW { Id = 3, Name = "Игра3" }, new BMW { Id = 4, Name = "Игра4" }, new BMW { Id = 5, Name = "Игра5" } }); BMWsController controller = new BMWsController(mock.Object); controller.pageSize = 3; // Act BMWsListViewModel result = (BMWsListViewModel)controller.List(2).Model; // Assert PagingInfo pageInfo = result.PagingInfo; Assert.AreEqual(pageInfo.CurrentPage, 2); Assert.AreEqual(pageInfo.ItemsPerPage, 3); Assert.AreEqual(pageInfo.TotalItems, 5); Assert.AreEqual(pageInfo.TotalPages, 2); }
public void Can_Paginate() { // Организация (arrange) // Организация (arrange) Mock <IBMWRepository> mock = new Mock <IBMWRepository>(); mock.Setup(m => m.BMWs).Returns(new List <BMW> { new BMW { Id = 1, Name = "Игра1" }, new BMW { Id = 2, Name = "Игра2" }, new BMW { Id = 3, Name = "Игра3" }, new BMW { Id = 4, Name = "Игра4" }, new BMW { Id = 5, Name = "Игра5" } }); BMWsController controller = new BMWsController(mock.Object); controller.pageSize = 3; // Act BMWsListViewModel result = (BMWsListViewModel)controller.List(2).Model; // Утверждение (assert) List <BMW> games = result.BMWs.ToList(); Assert.IsTrue(games.Count == 2); Assert.AreEqual(games[0].Name, "Игра4"); Assert.AreEqual(games[1].Name, "Игра5"); }