public void POST_User_Is_Logged_Out_If_Failing_To_Change_The_Password_For_Five_Times()
        {
            // Arrange
            User user = new UserBuilder().WithPassword("password").Build();

            var requestFormValues = new Dictionary <string, StringValues>();

            requestFormValues.Add("GovUk_Text_CurrentPassword", "incorrect_password");
            requestFormValues.Add("GovUk_Text_NewPassword", "Password1");
            requestFormValues.Add("GovUk_Text_ConfirmNewPassword", "Password1");

            var controller = new ControllerBuilder <ChangePasswordController>()
                             .WithLoggedInUser(user)
                             .WithRequestFormValues(requestFormValues)
                             .WithDatabaseObjects(user)
                             .WithMockUriHelper()
                             .Build();

            // Act
            controller.ChangePasswordPost(new ChangePasswordViewModel());
            controller.ChangePasswordPost(new ChangePasswordViewModel());
            controller.ChangePasswordPost(new ChangePasswordViewModel());
            controller.ChangePasswordPost(new ChangePasswordViewModel());
            var result = controller.ChangePasswordPost(new ChangePasswordViewModel()) as RedirectToActionResult;

            // Assert
            Assert.That(result != null, "Expected RedirectToActionResult");
            Assert.That(result.ActionName == "LoggedOut", "Expected redirect to LoggedOut");
        }
        public void POST_Password_Is_Updated_As_Expected()
        {
            // Arrange
            User user = new UserBuilder().WithPassword("password").Build();

            var requestFormValues = new Dictionary <string, StringValues>();

            requestFormValues.Add("GovUk_Text_CurrentPassword", "password");
            requestFormValues.Add("GovUk_Text_NewPassword", "NewPassword1");
            requestFormValues.Add("GovUk_Text_ConfirmNewPassword", "NewPassword1");

            var controller = new ControllerBuilder <ChangePasswordController>()
                             .WithLoggedInUser(user)
                             .WithRequestFormValues(requestFormValues)
                             .WithDatabaseObjects(user)
                             .WithMockUriHelper()
                             .Build();

            // Act
            controller.ChangePasswordPost(new ChangePasswordViewModel());

            // Assert
            bool isExpectedPassword = mockUserRepo.CheckPassword(user, "NewPassword1");

            Assert.IsTrue(isExpectedPassword);
        }