| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- package com.zipcodewilmington.bankaccountlab;
-
- import org.junit.*;
- import org.junit.jupiter.api.Test;
-
-
- public class ATMTest {
- ATM test =new ATM();
- CheckingAccount chadsChecking = new CheckingAccount(500.00, "Chad Hallinan");
- BusinessAccount chadsBusiness = new BusinessAccount(500.00,"Chad Hallinan");
- SavingsAccount chadsSavings= new SavingsAccount(500.00,"Chad Hallinan");
- BankAccount[] chads = new BankAccount[]{chadsChecking,chadsBusiness,chadsSavings};
-
- public ATMTest()
- {
- }
-
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- */
- @Before
- public void setUp()
- {
-
- }
-
- @Test
- public void withdrawTest(){
- //Given
-
- test.setAccounts(chads);
- test.withdraw(chadsChecking.getAccountNumber(), 300);
- //When
- double expected= 200;
- double actual = chadsChecking.getCurrentBalance();
- //Result
- Assert.assertEquals(expected, actual, 0);
-
- }
-
- @Test
- public void depositTest(){
- //Given
- test.setAccounts(chads);
- test.deposit(chadsChecking.getAccountNumber(), 300);
- //When
- double expected= 800;
- double actual = chadsChecking.getCurrentBalance();
- //Result
- Assert.assertEquals(expected, actual, 0);
-
- }
-
- @Test
- public void transferTest(){
- //Given
- test.setAccounts(chads);
- test.transfer(chadsChecking.getAccountNumber(), 300, chadsSavings.getAccountNumber());
- //When
- double expected= 800;
- double actual = chadsSavings.getCurrentBalance();
- //Result
- Assert.assertEquals(expected, actual, 0);
-
- }
-
- @Test
- public void changeAccountOwnerTest(){
- //Given
- test.setAccounts(chads);
- test.changeAccountOwner(chadsChecking.getAccountNumber(), "Sean Hallinan");
- //When
- String expected= "Sean Hallinan";
- String actual = chadsChecking.getOwnerName();
- //Result
- Assert.assertEquals(expected, actual);
-
- }
-
-
-
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @After
- public void tearDown()
- {
- }
- }
|