Exemplo n.º 1
0
        public void ChangePasswordTest()
        {   //Arrange
            //Act
            var result = CustomerController.ChangePassword();

            //Assert
            Assert.IsInstanceOfType(result, typeof(ViewResult));
        }
Exemplo n.º 2
0
        public void Task_Customer_ChangePassword()
        {
            //Arrange
            var controller = new CustomerController(context);
            //Act
            var result = controller.ChangePassword();

            //Arrange
            Assert.IsType <ViewResult>(result);
        }
Exemplo n.º 3
0
        public void ChangePassword()
        {
            var item = new UserDetails();

            item.UserDetailId = 1;
            item.Password     = "******";
            //Act
            IActionResult result = controller.ChangePassword();

            //Assert
            Assert.NotNull(result);
        }
Exemplo n.º 4
0
        public void ChangePassword_Get_ReturnsView()
        {
            // Arrange
            CustomerController controller = GetCustomerController();

            // Act
            ActionResult result = controller.ChangePassword();

            // Assert
            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.AreEqual(10, ((ViewResult)result).ViewData["PasswordLength"]);
        }
Exemplo n.º 5
0
        public void ChangePassword_Post_ReturnsRedirectOnSuccess()
        {
            // Arrange
            CustomerController  controller = GetCustomerController();
            ChangePasswordModel model      = new ChangePasswordModel()
            {
                OldPassword     = "******",
                NewPassword     = "******",
                ConfirmPassword = "******"
            };

            // Act
            ActionResult result = controller.ChangePassword(model);

            // Assert
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
            RedirectToRouteResult redirectResult = (RedirectToRouteResult)result;

            Assert.AreEqual("ChangePasswordSuccess", redirectResult.RouteValues["action"]);
        }
Exemplo n.º 6
0
        public void ChangePassword_Post_ReturnsViewIfChangePasswordFails()
        {
            // Arrange
            CustomerController  controller = GetCustomerController();
            ChangePasswordModel model      = new ChangePasswordModel()
            {
                OldPassword     = "******",
                NewPassword     = "******",
                ConfirmPassword = "******"
            };

            // Act
            ActionResult result = controller.ChangePassword(model);

            // Assert
            Assert.IsInstanceOfType(result, typeof(ViewResult));
            ViewResult viewResult = (ViewResult)result;

            Assert.AreEqual(model, viewResult.ViewData.Model);
            Assert.AreEqual("The current password is incorrect or the new password is invalid.", controller.ModelState[""].Errors[0].ErrorMessage);
            Assert.AreEqual(10, viewResult.ViewData["PasswordLength"]);
        }
Exemplo n.º 7
0
        public void ChangePassword_Post_ReturnsViewIfModelStateIsInvalid()
        {
            // Arrange
            CustomerController  controller = GetCustomerController();
            ChangePasswordModel model      = new ChangePasswordModel()
            {
                OldPassword     = "******",
                NewPassword     = "******",
                ConfirmPassword = "******"
            };

            controller.ModelState.AddModelError("", "Dummy error message.");

            // Act
            ActionResult result = controller.ChangePassword(model);

            // Assert
            Assert.IsInstanceOfType(result, typeof(ViewResult));
            ViewResult viewResult = (ViewResult)result;

            Assert.AreEqual(model, viewResult.ViewData.Model);
            Assert.AreEqual(10, viewResult.ViewData["PasswordLength"]);
        }