Skip to content

Commit

Permalink
Merge branch 'problem1' into 'main'
Browse files Browse the repository at this point in the history
Test: Make withdraw test

See merge request khkim6040/homework1!4
  • Loading branch information
khkim6040 committed Sep 19, 2023
2 parents 12adddb + 9b152ae commit cb8d767
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.postech.csed332.homework1;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -87,8 +88,19 @@ void testFindAccountByName() {
// compare
assertIterableEquals(accounts, expected_accounts);
}
// testTransferMoneyShouldFailif~~~
// testwithdrawshouldfailwhenamountisnegative
// testwithdrawshouldfailwhenamountismorethanbalance

@Test
void testWithdrawShouldBeFailedWhenBalanceIsInsufficient() {
String name = "Thomas";
Account account = wb.createAccount(name, 10, 0.01, false);
Assertions.assertThrows(IllegalStateException.class, () -> account.withdraw(11));
}

@Test
void testWithdrawShouldBeFailedWhenAmountIsNegative() {
String name = "Thomas";
Account account = wb.createAccount(name, 10, 0.01, false);
Assertions.assertThrows(IllegalStateException.class, () -> account.withdraw(-1));
}
}

0 comments on commit cb8d767

Please sign in to comment.