예제 #1
0
        public void InvokeIAuthOwnerService_GetAuthUsersOnPageOnceWithCorrectParameter(int pageNumber)
        {
            // Arrange
            var authOwnerService = new Mock <IAuthOwnerService>();

            var ownerController = new OwnerController(authOwnerService.Object);

            // Act
            ownerController.WithCallTo(c => c.GetUsersOnPage(pageNumber));

            // Assert
            authOwnerService.Verify(s => s.GetAuthUsersOnPage(pageNumber + 1), Times.Once);
        }
예제 #2
0
        public void InvokeIAuthOwnerService_GetAuthUsersOnPageMethodOnceWithCorrectParameter()
        {
            // Arrange
            var authOwnerService = new Mock <IAuthOwnerService>();

            var ownerController = new OwnerController(authOwnerService.Object);

            // Act
            ownerController
            .WithCallTo(c => c.Index())
            .ShouldRenderDefaultView();

            // Assert
            authOwnerService.Verify(s => s.GetAuthUsersOnPage(1), Times.Once);
        }
예제 #3
0
        public void InvokeIAuthOwnerService_GetAuthUsersOnPageOnceWithCorrectParameter()
        {
            // Arrange
            var authOwnerService = new Mock <IAuthOwnerService>();

            var ownerController = new OwnerController(authOwnerService.Object);

            var username   = "******";
            var pageNumber = 0;

            // Act
            ownerController.WithCallTo(c => c.Demote(username, pageNumber));

            // Assert
            authOwnerService.Verify(s => s.GetAuthUsersOnPage(pageNumber), Times.Once);
        }
예제 #4
0
        public void InvokeIAuthOwnerService_AddRoleAdminMethodOnceWithCorrectParameter()
        {
            // Arrange
            var authOwnerService = new Mock <IAuthOwnerService>();

            var ownerController = new OwnerController(authOwnerService.Object);

            var username   = "******";
            var pageNumber = 0;

            // Act
            ownerController.WithCallTo(c => c.Promote(username, pageNumber));

            // Assert
            authOwnerService.Verify(s => s.AddRoleAdmin(username), Times.Once);
        }
예제 #5
0
        public void RenderAuthUserViewModelsPartialViewWithCorrectViewModel(int pageNumber)
        {
            // Arrange
            var authOwnerService = new Mock <IAuthOwnerService>();

            var ownerController = new OwnerController(authOwnerService.Object);

            var expectedViewModel = new OwnerViewModel();

            authOwnerService.Setup(s => s.GetAuthUsersOnPage(It.IsAny <int>())).Returns(expectedViewModel);

            // Act & Assert
            ownerController
            .WithCallTo(c => c.GetUsersOnPage(pageNumber))
            .ShouldRenderPartialView("_AuthUserViewModelsPartial")
            .WithModel <OwnerViewModel>(actualViewModel =>
            {
                Assert.That(actualViewModel, Is.SameAs(expectedViewModel));
            });
        }