private void BtnAddMoney_Click(object sender, RoutedEventArgs e) { try { bankRekening.AddMoneyToBankAccount(GetMoneyAmountFromUser()); UpdateCurrentAmountLabel(); ClearInputMoneyAmount(); } catch (Exception ex) { MessageBox.Show($"Fout: {ex.Message}", "Fout!", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void AddMoneyToBankaccound_withValidMoney_UpdatesBalance() { //Arrange decimal beginningBalance = 10m; decimal money = 1m; decimal expected = 11m; BankRekening bankRekening = new BankRekening(beginningBalance); //Act bankRekening.AddMoneyToBankAccount(money); //Assert decimal actual = bankRekening.Balance; Assert.AreEqual(expected, actual, "Balance is incorrect"); }
public void AddMoneyToBankAccount_withValueMoney_UpdateBalance() { //Arrange decimal beginningBalance = 500.95m; decimal MoneyToAdd = 12.00m; decimal expected = 512.95m; BankRekening bankRekening = new BankRekening(beginningBalance); //Act bankRekening.AddMoneyToBankAccount(MoneyToAdd); //Assert decimal actual = bankRekening.Balance; Assert.AreEqual(expected, actual, "Balance is incorrect"); }
public void AddMoneyToBankAccount_WhenMoneyIsLessThanZero() { //Arrange try { decimal beginningBalance = 20.95m; decimal MoneyToAdd = -12.00m; BankRekening bankRekening = new BankRekening(beginningBalance); //Act bankRekening.AddMoneyToBankAccount(MoneyToAdd); } catch (ArgumentOutOfRangeException ex) { //Assert StringAssert.Contains(ex.Message, BankRekening.MoneyAmountLessThanZeroMessage); return; } Assert.Fail("No exception was thrown."); }