예제 #1
0
        public void DebitTest()
        {
            string customerName = "UnitTest01";
            double balance = 0.99;
            var target = new BankAccount(customerName, balance);

            double amount = -1.0;
            try
            {
                target.Debit(amount);
            }
            catch (ArgumentOutOfRangeException) { }
            catch (Exception ex)
            {
                Assert.Fail("Unexpected exception type " + ex.GetType().Name);
            }

            amount = 1.0;
            try
            {
                target.Debit(amount);
            }
            catch (ArgumentOutOfRangeException) { }
            catch (Exception ex)
            {
                Assert.Fail("Unexpected exception type " + ex.GetType().Name);
            }

            amount = balance;
            target.Debit(amount);
            Assert.AreEqual(target.Balance, balance - amount);
        }
예제 #2
0
        public void BankAccountConstructorTest()
        {
            string customerName = "UnitTest01";
            double balance = 0.99;
            var target = new BankAccount(customerName, balance);

            Assert.IsNotNull(target);
            Assert.AreEqual(target.CustomerName, customerName, true);
            Assert.AreEqual(target.Balance, balance);
        }
예제 #3
0
        public void GetBankAccountTest()
        {
            string customerName = "UnitTest01";
            double balance = 0.0;
            var expected = new BankAccount(customerName, balance);

            var actual = Program.GetBankAccount(customerName);

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.CustomerName, actual.CustomerName, true);
            Assert.AreEqual(expected.Balance, actual.Balance);
        }
예제 #4
0
파일: Program.cs 프로젝트: onlio-test/Demo
 public static void TransferMoney(BankAccount debitAccount, BankAccount creditAccount, double amount)
 {
     try
     {
         debitAccount.Debit(amount);
     }
     catch (ArgumentOutOfRangeException ex)
     {
         throw new ArgumentException("Insufficient balance.", ex);
     }
     creditAccount.Credit(amount);
 }
예제 #5
0
파일: Program.cs 프로젝트: onlio-test/Demo
 public static BankAccount GetBankAccount(string customerName)
 {
     var balance = GetBalance(customerName);
     var result = new BankAccount(customerName, balance);
     return result;
 }