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

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

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

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

            //Assert
            Assert.NotNull(result);
        }
Esempio 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"]);
        }
Esempio 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"]);
        }
Esempio 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"]);
        }
Esempio 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"]);
        }