public async Task <IActionResult> ChangePassword(ChangePasswordVM changePasswordVM) { try { await WalletService.ChangePassword(changePasswordVM.Jmbg, changePasswordVM.OldPassword, changePasswordVM.NewPassword, changePasswordVM.NewPasswordConfirmation); ModelState.Clear(); ViewData["IsSuccessful"] = "yes"; return(View()); } catch (Exception ex) { ViewData["IsSuccessful"] = "no"; ViewData["ErrorMessage"] = ex.Message; return(View()); } }
public async Task ChangePasswordSuccessTest() { try { //Arrange Configuration["FirstTransactionFreeEachMonth"] = "False"; var walletService = new WalletService(CoreUnitOfWork, BankRoutingService, Configuration, FeeService); string password = await walletService.CreateWallet("ime", "prezime", "0605996781029", (short)BankType.BrankoBank, "1234", "123456789876543210"); Wallet wallet = await CoreUnitOfWork.WalletRepository.GetById("0605996781029"); //Act await walletService.ChangePassword("0605996781029", password, "123456", "123456"); //Assert wallet = await CoreUnitOfWork.WalletRepository.GetById("0605996781029"); Assert.AreEqual(true, wallet.CheckPassword("123456"), "Password must be '123456'."); } catch (Exception ex) { Assert.Fail("Unexpected error: " + ex.Message); } }
public async Task ChangePasswordPasswordAndConfirmationDontMatchFailTest() { try { //Arrange Configuration["FirstTransactionFreeEachMonth"] = "False"; var walletService = new WalletService(CoreUnitOfWork, BankRoutingService, Configuration, FeeService); string password = await walletService.CreateWallet("ime", "prezime", "0605996781029", (short)BankType.BrankoBank, "1234", "123456789876543210"); //Act //Assert await Assert.ThrowsExceptionAsync <ArgumentException>(async() => await walletService.ChangePassword("0605996781029", "654321", "123456", "12345"), "New password and password confirmation do not match."); } catch (Exception ex) { Assert.Fail("Unexpected error: " + ex.Message); } }