コード例 #1
0
        public void admin_index_test()
        {
            // Arrange
            var authService = new Mock<IFormsAuthenticationService>();
            var demoService = new Mock<IDemoDataService>();

            //todo: mock https response

            // Act
            var controller = new AdminController(authService.Object, demoService.Object);
            var view = controller.NewTranslator();
            var view2 = controller.Users();
            var view3 = controller.Apps();

            demoService.Verify(x => x.GetAllApps(), Times.Once);
            demoService.Verify(x => x.GetAllUsers(), Times.Once);
            demoService.Verify(x => x.GetAUser(), Times.Once);
            // Assert
            Assert.NotNull(view);
            Assert.NotNull(view2);
            Assert.NotNull(view3);
        }
コード例 #2
0
        public void users_should_return_with_app_model()
        {
            // Arrange           
            var userService = new Mock<IUserService>();

            // Act
            var controller = new AdminController(userService.Object, null, null);
            var view = controller.Users(1);

            // Assert
            Assert.NotNull(view);
            controller.AssertGetAttribute("Users");
            userService.Verify(x => x.GetAllByRoleId(1), Times.Once);

            view = controller.Users(8);     // Methodta id>0 && id<4 olduğu için iki ayrı kontrol yaptık.

            // Assert
            Assert.NotNull(view);
            controller.AssertGetAttribute("Users");
            userService.Verify(x => x.GetAll(), Times.Once);
        }