Esempio n. 1
0
        public void Deposit_Execute_BalanceUpdatesOK()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            _ = deposit.Execute();
            Assert.Equal(200, account.Balance);
        }
Esempio n. 2
0
        public void Deposit_Executes_ExecutedIsTrue()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            _ = deposit.Execute();
            Assert.True(deposit.Executed);
        }
Esempio n. 3
0
        public void Deposit_Execute_StatusComplete()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            _ = deposit.Execute();
            Assert.Equal("Complete", deposit.Status);
        }
Esempio n. 4
0
        public void Deposit_Rollback_OK()
        {
            DepositTransaction deposit = new DepositTransaction(account, 100);

            _ = deposit.Execute();
            _ = deposit.Rollback();
            Assert.True(deposit.Reversed);
        }
Esempio n. 5
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());
        }
 private void DepositarATM()
 {
     try
     {
         ITransaction transacao = new DepositTransaction(new ATMUI(300));
         transacao.Execute();
         Console.WriteLine("Valor depositado com sucesso.");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
 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();
            }
        }
    }
Esempio n. 9
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);
     }
 }
Esempio n. 10
0
 private void ExecuteTransaction(DepositTransaction DepositTransaction)
 {
     DepositTransaction.Execute();
 }
Esempio n. 11
0
 public void ExecuteTransaction(DepositTransaction transaction)
 {
     transaction.Execute();
 }
Esempio n. 12
0
 public static void ExecuteTransaction(DepositTransaction transaction)
 {
     transaction.Execute();
     transaction.Print();
 }