1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
-
-
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- /**
- * The test class AccountTest.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class AccountTest
- {
- Account test = new Account();
-
- @Test
- public void transferTest(){
- //Given:
- test.deposit(1000);
- //Then:
- boolean expected = true;
- boolean actual = test.transfer(test, 999);
- //Assert:
- assertEquals(expected, actual);
- }
-
- @Test
- public void balanceTest(){
- //Given:
- test.deposit(1000);
- //Then:
- int expected = 1000;
- int actual = test.balance();
- //Assert:
- assertEquals(expected, actual);
- }
-
- @Test
- public void depositTest(){
- //Given:
- Account test = new Account(100);
- test.deposit(100);
- //Then:
- int expected = 200;
- int actual = test.balance();
- //Assert
- assertEquals(expected,actual);
-
- }
-
- @Test
- public void openTest() {
- //Given
- Account test = new Account(100);
- //Then:
- Account answer = test.open(90);
- //Assert
- assertTrue(answer.balance() == 90);
-
- }
-
- @Test
- public void withdrawTest(){
- test.deposit(1000);
- try{test.withdraw(800);}
- catch(AccountException ae){};
- int expected = 200;
- int actual = test.balance();
- assertEquals(expected,actual);
- }
- }
|