/** Test method for {@link edu.cecs274.BankCustomer#getTotalBalance()}. */ @Test public void testGetTotalBalance() { BankAccount oneAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER, INITIAL_BALANCE); BankAccount twoAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER + 1); BankAccount threeAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER + 2); aCustomer.addAccount(oneAccount); aCustomer.addAccount(twoAccount); aCustomer.addAccount(threeAccount); double expected = INITIAL_BALANCE; double totalBalance = aCustomer.getTotalBalance(); assertEquals(expected, totalBalance, DELTA); // Adds more money to twoAccount, the change should be reflected in aCustomers totalBalance twoAccount.deposit(INITIAL_BALANCE); expected = INITIAL_BALANCE * 2; totalBalance = aCustomer.getTotalBalance(); assertEquals(expected, totalBalance, DELTA); }
/** Test method for {@link edu.cecs274.BankCustomer#addAccount(edu.cecs274.BankAccount)}. */ @Test public void testAddAccount() { // Initially, aCustomer has no bank accounts int numberOfAccounts = aCustomer.getNumberOfAccounts(); double totalBalance = aCustomer.getTotalBalance(); BankAccount newAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER); aCustomer.addAccount(newAccount); // Now aCustomer has a newAccount with the default initial balance assertEquals(++numberOfAccounts, aCustomer.getNumberOfAccounts()); assertEquals(totalBalance, aCustomer.getTotalBalance(), DELTA); // Add another account with a balance newAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER + 1, INITIAL_BALANCE); aCustomer.addAccount(newAccount); // Now aCustomer has two accounts, with totalBalance == INITIAL_BALANCE assertEquals(++numberOfAccounts, aCustomer.getNumberOfAccounts()); assertEquals(totalBalance + INITIAL_BALANCE, aCustomer.getTotalBalance(), DELTA); }
/** * Test method for {@link edu.cecs274.BankCustomer#BankCustomer(java.lang.String, * java.lang.String)}. */ @Test public void testBankCustomer() { int expected = 0; // aCustomer should have no accounts, so no balance assertEquals(expected, aCustomer.getNumberOfAccounts()); assertEquals(expected, aCustomer.getTotalBalance(), DELTA); assertEquals(FIRST_NAME, aCustomer.getFirstName()); assertEquals(LAST_NAME, aCustomer.getLastName()); // // id should be a value >= 1 // assertTrue(aCustomer >= 1); }