-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
655f8b6
commit 2a7211e
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import static org.junit.Assert.*; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
//assertEquals(expected, actual, 0.001) delta is for precision | ||
public class BankAccountTest { | ||
BankAccount testAccount; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
testAccount = new BankAccount("Test case", 123.45); | ||
} | ||
|
||
@Test | ||
public void testWithdraw() { | ||
testAccount.withdraw(23.64); | ||
assertEquals("Test case $99.81", testAccount.toString()); | ||
} | ||
|
||
@Test | ||
public void testAddInterest() { | ||
BankAccount.setInterestRate(5.0); | ||
testAccount.addInterest(); | ||
assertEquals("Test Case $123.96", testAccount.toString()); | ||
} | ||
|
||
@Test | ||
public void testIsBalanceOver() { | ||
// First Parameter is the expected result, the second result is the | ||
// actual result | ||
assertTrue(testAccount.isBalanceOver(123.43)); | ||
assertTrue(testAccount.isBalanceOver(123.44)); | ||
assertFalse(testAccount.isBalanceOver(123.45)); | ||
assertFalse(testAccount.isBalanceOver(123.46)); | ||
} | ||
|
||
} |