コード例 #1
0
        public void Test_BanUser_Return_Right_Model_In_View()
        {
            //arrange
            UsersController controller = new UsersController(_userService.Object);

            //act
            ViewResult result = controller.BanUser( 1 );

            //assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, (result.Model as BanUserViewModel).UserId);
        }
コード例 #2
0
        public void Test_BanUser_Call_BanUser_With_Right_TimeSpan_Param()
        {
            //arrange
            UsersController controller = new UsersController(_userService.Object);
            BanUserViewModel model = new BanUserViewModel()
            {
                UserId = 1,
                BanDuration = "1:00:00"
            };

            //act
            controller.BanUser(model);

            //assert
            _userService.Verify(u => u.BanUser(It.IsAny<int>(), It.Is<TimeSpan>( t => t.Hours == 1 )), Times.Once());
        }