Exemple #1
0
        public void TestUnban_ShouldReturnRedirectToActionWithCorrectPage(string userId, int page)
        {
            // Arrange
            var mockedAuthenticationProvider = new Mock <IAuthenticationProvider>();
            var mockedUserService            = new Mock <IUserService>();

            var controller = new UserAdministrationController(mockedUserService.Object, mockedAuthenticationProvider.Object);

            // Act, Assert
            controller
            .WithCallTo(c => c.Unban(userId, page))
            .ShouldRedirectTo(c => c.Index(page, It.IsAny <int>()));
        }
Exemple #2
0
        public void TestIndex_ShouldReturnPagedListWithCorrectPage(int page, int count)
        {
            // Arrange
            var users = new List <User> {
                new User(), new User()
            };

            var mockedAuthenticationProvider = new Mock <IAuthenticationProvider>();

            var mockedUserService = new Mock <IUserService>();

            mockedUserService.Setup(s => s.GetUsers()).Returns(users);

            var controller = new UserAdministrationController(mockedUserService.Object, mockedAuthenticationProvider.Object);

            // Act, Assert
            controller
            .WithCallTo(c => c.Index(page, count))
            .ShouldRenderDefaultView()
            .WithModel <IPagedList <UserViewModel> >(m => Assert.AreEqual(page, m.PageNumber));
        }