public static void AssertModel(this ResetPasswordModel model,
                                ResetPasswordModel source)
 {
     Assert.AreEqual(source.Username, model.Username);
     Assert.AreEqual(source.Question, model.Question);
     Assert.AreEqual(source.Answer, model.Answer);
 }
 private void AssertResetPasswordOnError(ActionResult result,
                                         ResetPasswordModel model, string errorkey, string errormessage)
 {
     controller.ViewData.ModelState.AssertErrorMessage(errorkey, errormessage);
     result.AssertViewResult(controller, "Reset Password");
     model.AssertModel((ResetPasswordModel) controller.ViewData.Model);
 }
        public void ResetPasswordQuestion_Returns_Error_If_Provider_Throws_Exception()
        {
            var wronganswer = "wrong answer";
            mocks.MembershipProvider
                .Expect(p => p.ResetPassword(username, wronganswer))
                .Throws<Exception>();

            var inModel = new ResetPasswordModel
                              {
                                  Question = question,
                                  Username = username,
                                  Answer = wronganswer
                              };
            var result = controller.ResetPasswordQuestionSubmit(inModel);
            AssertResetPasswordOnError(result, inModel, "error",
                                       "There was an error resetting the password.");
            mocks.MembershipProvider.VerifyAll();
        }
        public void ResetPasswordQuestion_Returns_Error_If_Answer_Is_Wrong()
        {
            var wronganswer = "wrong answer";
            mocks.MembershipProvider
                .Expect(p => p.ResetPassword(username, wronganswer))
                .Throws<MembershipPasswordException>();

            var inModel = new ResetPasswordModel
                              {
                                  Question = question,
                                  Username = username,
                                  Answer = wronganswer
                              };
            var result = controller.ResetPasswordQuestionSubmit(inModel);
            AssertResetPasswordOnError(result, inModel, "answer", "You entered the wrong answer.");
            mocks.MembershipProvider.VerifyAll();
        }
 public void ResetPasswordQuestion_Returns_Error_If_Answer_Is_Empty()
 {
     var inModel = new ResetPasswordModel
                       {
                           Question = question,
                           Username = username
                       };
     var result = controller.ResetPasswordQuestionSubmit(inModel);
     AssertResetPasswordOnError(result, inModel, "answer", "Answer is required");
 }