Ejemplo n.º 1
0
 public static Customer CreateValidCustomer()
 {
     return(new Customer("1234567890", "Rasmus Naver", new List <Account>()
     {
         CheckingAccountTestClass.CreateValidCheckingAccount(), SavingAccountTestClass.CreateValidSavingAccount()
     }));
 }
Ejemplo n.º 2
0
        public void TransactionDateTimeIsInTheFutureTest()
        {
            CheckingAccount account1 = CheckingAccountTestClass.CreateValidCheckingAccount();
            CheckingAccount account2 = CheckingAccountTestClass.CreateValidCheckingAccount();

            Transaction transaction = new Transaction(1, new DateTime(2019, 1, 1), account1, account2);
        }
Ejemplo n.º 3
0
        public void TransactionAmountEqualToOrLessThanZeroTest()
        {
            CheckingAccount account1 = CheckingAccountTestClass.CreateValidCheckingAccount();
            CheckingAccount account2 = CheckingAccountTestClass.CreateValidCheckingAccount();

            Transaction transaction = new Transaction(0, DateTime.Now, account1, account2);
        }
Ejemplo n.º 4
0
        public void AccountPerformTransactionWhenTransactionAmountExceedsBalanceOfTransmittingAccount()
        {
            CheckingAccount account1    = CheckingAccountTestClass.CreateValidCheckingAccount();
            CheckingAccount account2    = CheckingAccountTestClass.CreateValidCheckingAccount();
            Transaction     transaction = new Transaction(500, DateTime.Now, account1, account2);

            account1.PerformTransaction(transaction);
        }
Ejemplo n.º 5
0
        public void AccountPerformTransactionDoesNotIncludeActingAccount()
        {
            CheckingAccount account1    = CheckingAccountTestClass.CreateValidCheckingAccount();
            CheckingAccount account2    = CheckingAccountTestClass.CreateValidCheckingAccount();
            CheckingAccount account3    = CheckingAccountTestClass.CreateValidCheckingAccount();
            Transaction     transaction = new Transaction(1, DateTime.Now, account1, account2);

            account3.PerformTransaction(transaction);
        }
Ejemplo n.º 6
0
        public void ValidInputConstructorTest()
        {
            CheckingAccount account1 = CheckingAccountTestClass.CreateValidCheckingAccount();
            CheckingAccount account2 = CheckingAccountTestClass.CreateValidCheckingAccount();

            Transaction transaction = new Transaction(1, DateTime.Now, account1, account2);

            Assert.AreEqual("137", transaction.Transmitter.AccountNumber);
        }
Ejemplo n.º 7
0
        public void CustomerCalculateCostOfMonthTest()
        {
            Customer        customer                      = CreateValidCustomer();
            CheckingAccount checkingAccount               = CheckingAccountTestClass.CreateValidCheckingAccount();
            decimal         transactionCost               = customer.TransactionCost;
            decimal         monthlyCost                   = customer.MonthlyAccountFee;
            decimal         numberOfTransactionFees       = 0;
            Transaction     transaction1                  = new Transaction(1, DateTime.Now, customer.Accounts[0], checkingAccount);
            Transaction     transaction2                  = new Transaction(1, DateTime.Now, customer.Accounts[1], checkingAccount);
            int             numberOfTransaction1Performed = 21;
            int             numberOfTransaction2Performed = 2;

            for (int i = 0; i < numberOfTransaction1Performed; i++)
            {
                customer.Accounts[0].PerformTransaction(transaction1);
            }

            for (int i = 0; i < numberOfTransaction2Performed; i++)
            {
                customer.Accounts[1].PerformTransaction(transaction2);
            }

            foreach (Account a in customer.Accounts)
            {
                if (a is CheckingAccount && a.Transactions.Count > CheckingAccount.noMonthlyFreeTransactions)
                {
                    numberOfTransactionFees += a.Transactions.Count - CheckingAccount.noMonthlyFreeTransactions;
                }
                else
                {
                    numberOfTransactionFees += a.Transactions.Count;
                }
            }
            Month month = (Month)DateTime.Now.Month;


            decimal costOfMonth = customer.CalculateCostOfMonth(month);


            Assert.AreEqual((monthlyCost * customer.Accounts.Count) + (transactionCost * numberOfTransactionFees), costOfMonth);
        }