public void Withdraw_Execute_StatusComplete()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            _ = withdraw.Execute();
            Assert.Equal("Complete", withdraw.Status);
        }
        public void Withdraw_Execute_BalanceUpdatesOK()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            _ = withdraw.Execute();
            Assert.Equal(0, account.Balance);
        }
        public void Withdraw_Executes_ExecutedIsTrue()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            _ = withdraw.Execute();
            Assert.True(withdraw.Executed);
        }
        public void Withdraw_Rollback_BalanceUpdatesOK()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            withdraw.Execute();
            withdraw.Rollback();
            Assert.Equal(100, account.Balance);
        }
        public void Withdraw_Rollback_OK()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

            _ = withdraw.Execute();
            _ = withdraw.Rollback();
            Assert.True(withdraw.Reversed);
        }
Ejemplo n.º 6
0
        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 Transfer_RollbackWithInsufficientFunds_ThrowsInsufficientFundsException()
        {
            TransferTransaction transfer = new TransferTransaction(from, to, 50);

            _ = transfer.Execute();

            WithdrawTransaction withdraw = new WithdrawTransaction(to, to.Balance);

            withdraw.Execute();

            Assert.Throws <InsufficientFundsException>(() => transfer.Rollback());
        }
 public override void Execute()
 {
     _theWithdraw.Execute();
     if (_theWithdraw.Success == true)
     {
         _theDeposit.Execute();
         if (_theDeposit.Success != true)
         {
             _theDeposit.Rollback();
         }
         else
         {
             base.Execute();
             _success = true;
         }
     }
 }
    public override void Execute()
    {
        base.Execute();

        _theWithdrawTransaction.Execute();

        if (_theWithdrawTransaction.Success)
        {
            _theDepositTransaction.Execute();

            if (_theDepositTransaction.Success)
            {
                _executed = true;

                _success = true;
            }

            else
            {
                _theDepositTransaction.Rollback();
            }
        }
    }
Ejemplo n.º 10
0
 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);
     }
 }
Ejemplo n.º 11
0
 private void ExecuteTransaction(WithdrawTransaction WithdrawTransaction)
 {
     WithdrawTransaction.Execute();
 }
Ejemplo n.º 12
0
 public void ExecuteTransaction(WithdrawTransaction transaction)
 {
     transaction.Execute();
 }
Ejemplo n.º 13
0
 public static void ExecuteTransaction(WithdrawTransaction transaction)
 {
     transaction.Execute();
     transaction.Print();
 }