Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void testWithdraw() {
- //Create account with the following information
- Account myBankAccount = new Account(100.0, "SEK", 250.0);
- assertEquals("The value of the account shall be 100", 100.0, myBankAccount.getBalance(), 0);
- //Amount to withdraw and check that it isn't a negative value
- double amountToWithdraw = 50.0;
- assertTrue(amountToWithdraw > 0);
- //Make sure that the amount we want to withdraw isn't higher than the amount allowed
- double maxWithdrawAmount = myBankAccount.getBalance() + myBankAccount.getMaxOverdrawn();
- assertTrue((maxWithdrawAmount - amountToWithdraw) > 0);
- //Proceed with the withdrawel and make sure it is correct
- myBankAccount.withdraw(amountToWithdraw);
- assertEquals("The value of the account shall be 50", 50.0, myBankAccount.getBalance(), 0);
- }
- @Test
- public void testDeposit() {
- //Create account with the following information
- Account myBankAccount = new Account(100.0, "SEK", 250.0);
- assertEquals("The value of the account shall be 100", 100.0, myBankAccount.getBalance(), 0);
- //Amount to deposit and in what currency that is
- double amountToDeposit = 100.0;
- String depCurrCode = "SEK";
- //Checks that the currency is the same
- assertEquals(depCurrCode,myBankAccount.getCurrency());
- //This assert performs a check where it makes sure that the value that is inputet is not of
- //negative value, since you can only deposit positive amount of money.
- assertTrue( amountToDeposit > 0);
- //Perform the deposit and check that it is correct
- myBankAccount.deposit(amountToDeposit);
- assertEquals("The value of the account shall be 200", 200.0, myBankAccount.getBalance(), 0);
- }
- @Test
- public void testConvertToCurrency() {
- Account myBankAccount = new Account(100.0, "SEK", 250.0);
- assertEquals("The value of the account shall be 100", 100.0, myBankAccount.getBalance(), 0);
- //Make The conversition to US dollars
- String convertToString = "USD";
- double currRate = 1.2;
- //Make sure that the currency we want to convert to isn't the currency already applied on the account.
- assertEquals(convertToString, myBankAccount.getCurrency());
- myBankAccount.convertToCurrency(convertToString, currRate);
- //Make sure the conversition went ok
- assertEquals(120.0, myBankAccount.getBalance(), 0);
- assertEquals(convertToString, myBankAccount.getCurrency());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement