public async Task AccountChangePasswordPostSuccess()
 {
     this.userManagerMock.Setup(mock => mock.ChangePasswordAsyncWrap(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(IdentityResult.Success));
     this.accountController.UserManager = this.userManagerMock.Object;
     var model = new ChangePasswordViewModel { OldPassword = "******", NewPassword = "******" };
     var result = await this.accountController.ChangePassword(model);
     this.signInManangerMock.Verify(m => m.RelogonUserAsyncWrap(this.webUser, false), Times.Once);
     result.Should().BeRedirectToRouteResult().WithAction("userprofile");
 }
 public async Task AccountChangePasswordPostFailure()
 {
     this.userManagerMock.Setup(mock => mock.ChangePasswordAsyncWrap(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(IdentityResult.Failed()));
     this.accountController.UserManager = this.userManagerMock.Object;
     var model = new ChangePasswordViewModel { OldPassword = "******", NewPassword = "******" };
     var result = await this.accountController.ChangePassword(model);
     this.signInManangerMock.Verify(m => m.RelogonUserAsyncWrap(this.webUser, false), Times.Never);
     result.Should().BeViewResult().WithViewName("~/Features/Account/ChangePassword.cshtml");
 }
        public virtual async Task<ActionResult> ChangePassword(ChangePasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return this.View(MVC.Account.Views.ChangePassword, model);
            }

            var result = await this.UserManager.ChangePasswordAsyncWrap(int.Parse(User.Identity.GetUserId()), model.OldPassword, model.NewPassword);
            if (result.Succeeded)
            {
                var user = await this.UserManager.FindByIdAsyncWrap(int.Parse(User.Identity.GetUserId()));
                if (user != null)
                {
                    await this.SignInManager.RelogonUserAsyncWrap(user, false);
                }

                // TODO: Add master data translations for those
                this.WebMessages.AddSuccessMessage(this.T("Change password"), this.T("Password change was success"));
                return this.RedirectToAction(MVC.Account.UserProfile());
            }

            foreach (var errorMessage in result.Errors)
            {
                this.WebMessages.AddErrorMessage(errorMessage);
            }

            return this.View(MVC.Account.Views.ChangePassword, model);
        }