Esempio n. 1
0
 public void Test_Deposit_Success()
 {
     AccountsLib.Account acc = new AccountsLib.Account(3);
     acc.Deposit(3);
     acc.Deposit(2);
     Assert.AreEqual(5, acc.Balance);
 }
Esempio n. 2
0
 public void Test_DepositMax_Failed()
 {
     AccountsLib.Account acc = new AccountsLib.Account(3);
     acc.Deposit(3);
     try
     {
         acc.Deposit(int.MaxValue);
         Assert.Fail();
     }
     catch (OverflowException)
     {
         Assert.Pass();
     }
 }
Esempio n. 3
0
 public void Test_DepositNegative_Failed()
 {
     AccountsLib.Account acc = new AccountsLib.Account(3);
     acc.Deposit(3);
     try
     {
         acc.Deposit(-2);
         Assert.Fail();
     }
     catch (Exception e)
     {
         Assert.AreEqual("NegativeExc", e.Message);
     }
 }
Esempio n. 4
0
 public void Test_TransferNegative_Failed()
 {
     AccountsLib.Account acc  = new AccountsLib.Account(3);
     AccountsLib.Account acc2 = new AccountsLib.Account(5);
     acc.Deposit(3);
     Assert.AreEqual(false, acc.Transfer(acc2, 4));
 }
Esempio n. 5
0
 public void Test_Withdraw_Success()
 {
     AccountsLib.Account acc = new AccountsLib.Account(3);
     acc.Deposit(3);
     acc.Withdraw(2);
     Assert.AreEqual(1, acc.Balance);
 }
        public static void DepositToAccount(Account account)
        {
            var depositAmount = GetAmountFromUser("Enter the amount to deposit: ");
            account.Deposit(depositAmount);

            var successMessage = string.Format("{0}$ has been deposited to Account {1}", depositAmount, account.Id);
            MessagesPrinter.SuccessMessage(successMessage);
        }
Esempio n. 7
0
 public void Test_Transfer_Success()
 {
     AccountsLib.Account acc  = new AccountsLib.Account(3);
     AccountsLib.Account acc2 = new AccountsLib.Account(5);
     acc.Deposit(3);
     Assert.AreEqual(true, acc.Transfer(acc2, 2));
     Assert.AreEqual(1, acc.Balance);
     Assert.AreEqual(2, acc2.Balance);
 }
Esempio n. 8
0
 public void Test_WithdrawTooMuch_Failed()
 {
     AccountsLib.Account acc = new AccountsLib.Account(3);
     acc.Deposit(2);
     try
     {
         acc.Withdraw(3);
         Assert.Fail();
     }
     catch (InsufficentFundsException)
     {
         Assert.Pass();
     }
 }
Esempio n. 9
0
 static void Main(string[] args)
 {
     AccountsLib.Account newAcc = AccountsLib.AccountFactory.CreateAccount(0);
     newAcc.Deposit(50);
     try
     {
         newAcc.Withdraw(51);
     }
     //You are not handling the ArgumentOutOfRangeException/Exception that you throwed if the amount is negative.
     catch (InsufficentFundsException e)
     {
         //You should have used the message from the exception
         Console.WriteLine("there has been an InsufficentFundsException");
     }
     finally //didn't understood why we need the finally now but i did it
     {
         newAcc.Withdraw(29);
         AccountsLib.Account newAcc2 = AccountsLib.AccountFactory.CreateAccount(0);
         newAcc.Transfer(newAcc2, 5);
         Console.WriteLine("{0} {1}", newAcc.Balance, newAcc2.Balance);
         Console.ReadLine();
     }
 }
Esempio n. 10
0
        }     // Balance property

        public void Transfer(Account acc, int amount)
        {
            acc.Deposit(Withdraw(amount));
        } // Transfer
 public static void DepositToAccount(Account account)
 {
     var depositAmount = GetAmountFromUser("Enter the amount to deposit: ");
     account.Deposit(depositAmount);
 }