public ActionResult ChangePassword(ChangePasswordViewModel model)
 {
     if (ModelState.IsValid)
     {
         if (accountRepository.ChangePassword(model.Email, model.Password))
         {
             this.Success(string.Format("Password for {0} has been saved", model.Email));
         }
         else
         {
             this.Error(string.Format("Password not changed"));
         }
     }
     User retmodel = accountRepository.GetUserByEmail(model.Email);
     return View("PersonalPage", retmodel);
 }
        public void Can_Change_Password()
        {
            // Arrange
            ChangePasswordViewModel model = new ChangePasswordViewModel
            {
                Email = "*****@*****.**",
                Password = "******",
                PasswordAgain = "newPass123"
            };

            // Act
            ActionResult res = accountController.ChangePassword(model);

            // Assert
            mock.Verify(m => m.ChangePassword(model.Email, model.Password));
            Assert.IsInstanceOf(typeof(ViewResult), res);
        }
        public void Can_Not_Change_Password()
        {
            // Arrange
            ChangePasswordViewModel model = new ChangePasswordViewModel
            {
                Email = "*****@*****.**",
                Password = "******",
                PasswordAgain = "newPass123"
            };

            // Act
            ActionResult res = accountController.ChangePassword(model);
            accountController.ModelState.AddModelError("error", "Invalid email");

            // Assert
            Assert.IsInstanceOf(typeof(ViewResult), res);
        }
 public ActionResult ChangePasswordPartial()
 {
     ChangePasswordViewModel user = new ChangePasswordViewModel
     {
         Email = HttpContext.User.Identity.Name
     };
     return PartialView("_ChangePassword", user);
 }