Beispiel #1
0
        public void Test_Can_Send_Pagination_View_Model()
        {
            //Arrange
            Mock <INewsRepository> mock_repository = new Mock <INewsRepository>();

            mock_repository.Setup(m => m.Users).Returns(new DAL.DataBase.User[] {
                new DAL.DataBase.User {
                    Id = 1, UserName = "******", Role = "r1"
                },
                new DAL.DataBase.User {
                    Id = 2, UserName = "******", Role = "r2"
                },
                new DAL.DataBase.User {
                    Id = 3, UserName = "******", Role = "r3"
                },
                new DAL.DataBase.User {
                    Id = 4, UserName = "******", Role = "r4"
                },
                new DAL.DataBase.User {
                    Id = 5, UserName = "******", Role = "r5"
                },
            });


            //Arrange
            UserManagementController controller = new UserManagementController(new NewsAgencyService(), mock_repository.Object);
            var result = (UserListViewModel)((ViewResult)controller.ManageUsers(2)).Model;

            PagingInfo pageInfo = result.PagingInfo;

            Assert.AreEqual(pageInfo.CurrentPage, 2);
            Assert.AreEqual(pageInfo.ItemsPerPage, 3);
            Assert.AreEqual(pageInfo.TotalItems, 5);
            Assert.AreEqual(pageInfo.TotalPages, 2);
        }