Пример #1
0
 public void Rollback()
 {
     try
     {
         if (!Executed)
         {
             throw new Exception("Transaction has not been executed.");
         }
         if (!Reversed)
         {
             throw new Exception("Transaction has been reversed.");
         }
         if (_theWithdraw.Success)
         {
             _theWithdraw.Rollback();
         }
         if (_theDeposit.Success)
         {
             _theDeposit.Rollback();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Transfer rollback error! " + e.Message);
     }
 }
        public void Withdraw_Rollback_OK()
        {
            WithdrawTransaction withdraw = new WithdrawTransaction(account, 100);

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

            withdraw.Execute();
            withdraw.Rollback();
            Assert.Equal(100, account.Balance);
        }
    public override void Rollback()
    {
        base.Rollback();

        if (_theWithdrawTransaction.Success)
        {
            _theWithdrawTransaction.Rollback();
        }
    }
    public override void Rollback()
    {
        if (_theWithdraw.Success == false)
        {
            _theWithdraw.Rollback();
        }

        if (_theDeposit.Success == false)
        {
            _theDeposit.Rollback();
        }

        base.Rollback();
    }