Example #1
0
        public void Bank_Constructor_Should_Succeed_When_Creating_New_Bank_With_Multiple_Accounts()
        {
            Owner owner1 = new Owner("1", "Joe");
            Owner owner2 = new Owner("2", "Walmart");

            Account acct1 = new CheckingAccount(owner1, "1", 2000.76);
            Account acct2 = new IndividualInvestmentAccount(owner1, "2", 500.00);
            Account acct3 = new CorporateInvestmentAccount(owner2, "3", 7000000.00);

            List <Account> chaseAccounts = new List <Account>
            {
                acct1,
                acct2,
                acct3
            };

            Bank chaseBank = new Bank("1", "Chase", chaseAccounts);

            Assert.AreEqual("1", chaseBank.Id);
            Assert.AreEqual("Chase", chaseBank.Name);
            Assert.AreEqual(chaseAccounts.Count, chaseBank.Accounts.Count);
            Assert.IsTrue(chaseBank.Accounts[0] is CheckingAccount);
            Assert.AreEqual(owner1.Id, chaseBank.Accounts[0].Owner.Id);
            Assert.AreEqual(owner1.Name, chaseBank.Accounts[0].Owner.Name);
            Assert.IsTrue(chaseBank.Accounts[1] is IndividualInvestmentAccount);
            Assert.AreEqual(owner1.Id, chaseBank.Accounts[0].Owner.Id);
            Assert.AreEqual(owner1.Name, chaseBank.Accounts[1].Owner.Name);
            Assert.IsTrue(chaseBank.Accounts[2] is CorporateInvestmentAccount);
            Assert.AreEqual(owner1.Id, chaseBank.Accounts[0].Owner.Id);
            Assert.AreEqual(owner2.Name, chaseBank.Accounts[2].Owner.Name);
        }
Example #2
0
        public void CorporateInvestmentAccount_Constructor_Should_Fail_When_Creating_New_Account_Without_Owner()
        {
            Exception caughtException = null;

            try
            {
                Account badAcct = new CorporateInvestmentAccount(null, "3", 100000.54);
            }
            catch (Exception ex)
            {
                caughtException = ex;
            }

            Assert.IsNotNull(caughtException);
            Assert.AreEqual("Account must have an owner", caughtException.Message);
        }
Example #3
0
        public void DepositTest()
        {
            Customer owner = new Customer();

            owner.CustomerName      = "John Smith";
            owner.CustomerAccountId = 1231;

            IndividualInvestmentAccount individualAccount = new IndividualInvestmentAccount(9000, owner);

            individualAccount.Deposit(1000);
            Assert.AreEqual(10000, individualAccount.Balance);

            CorporateInvestmentAccount CorpAccount = new CorporateInvestmentAccount(4454.45M, owner);

            CorpAccount.Deposit(5545.55M);
            Assert.AreEqual(10000, CorpAccount.Balance);

            CheckingAccount checkingAccount = new CheckingAccount(1300, owner);

            checkingAccount.Deposit(1200);
            Assert.AreEqual(2500, checkingAccount.Balance);
        }