/** * Test method for {@link edu.cecs274.BankCustomer#closeAccount(edu.cecs274.BankAccount)}. Cancels * an account that exist in aCustomer's list of accounts. */ @Test public void testCancelAccount() { // Add two accounts to aCustomer's list of accounts BankAccount oneAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER); aCustomer.addAccount(oneAccount); BankAccount anotherAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER + 1); aCustomer.addAccount(anotherAccount); int expected = 2; assertEquals(expected, aCustomer.getNumberOfAccounts()); // Cancel an account, should remove from aCustomer's list of accounts aCustomer.closeAccount(oneAccount); assertEquals(--expected, aCustomer.getNumberOfAccounts()); }
/** * Test method for {@link edu.cecs274.BankCustomer#closeAccount(edu.cecs274.BankAccount)}. Cancels * an account that does not exist in aCustomer's list of accounts. */ @Test(expected = AccountDoesNotExistException.class) public void testCancelAccountDoesNotExist() { // Add two accounts to aCustomer's list of accounts BankAccount oneAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER); aCustomer.addAccount(oneAccount); BankAccount anotherAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER + 1); aCustomer.addAccount(anotherAccount); int expected = 2; assertEquals(expected, aCustomer.getNumberOfAccounts()); // Cancel an account that does not exist in aCustomer's list of accounts BankAccount newAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER - 1); aCustomer.closeAccount(newAccount); }