public void Deposit_Rollback_BalanceUpdatesOK() { DepositTransaction deposit = new DepositTransaction(account, 100); _ = deposit.Execute(); _ = deposit.Rollback(); Assert.Equal(100, account.Balance); }
public void Deposit_Rollback_OK() { DepositTransaction deposit = new DepositTransaction(account, 100); _ = deposit.Execute(); _ = deposit.Rollback(); Assert.True(deposit.Reversed); }
public override void Execute() { _theWithdraw.Execute(); if (_theWithdraw.Success == true) { _theDeposit.Execute(); if (_theDeposit.Success != true) { _theDeposit.Rollback(); } else { base.Execute(); _success = true; } } }
public void Deposit_Rollback_InsufficientFundsThrowsInsufficientFundsException() { DepositTransaction deposit = new DepositTransaction(account, 100); _ = deposit.Execute(); WithdrawTransaction withdraw = new WithdrawTransaction(account, 150); _ = withdraw.Execute(); Assert.Throws <InsufficientFundsException>(() => deposit.Rollback()); }
public void Execute() { try { if (Executed) { throw new Exception("Cannot execute this transaction as it has already been performed."); } _executed = true; _theWithdraw.Execute(); if (_theWithdraw.Success) { _theDeposit.Execute(); } else if (!_theDeposit.Success) { _theDeposit.Rollback(); } } catch (Exception e) { Console.WriteLine("Transfer execute error! " + e.Message); } }
public override void Execute() { base.Execute(); _theWithdrawTransaction.Execute(); if (_theWithdrawTransaction.Success) { _theDepositTransaction.Execute(); if (_theDepositTransaction.Success) { _executed = true; _success = true; } else { _theDepositTransaction.Rollback(); } } }