forked from nus-cs2113-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JUnit test for TransactionList class
- Loading branch information
Isaac Eng
committed
Mar 14, 2024
1 parent
ac9abbb
commit 08c74a0
Showing
1 changed file
with
32 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,4 +1,35 @@ | ||
package financemanager; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import transactions.Transaction; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class TransactionListTest { | ||
} | ||
|
||
private TransactionList transactionList; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
transactionList = new TransactionList(); | ||
} | ||
|
||
@Test | ||
public void getTransactions_initiallyEmpty() { | ||
assertEquals(0, transactionList.getTransactions().size()); | ||
} | ||
|
||
@Test | ||
public void processTransaction_addsTransaction() { | ||
Transaction testTransaction = new Transaction("Test", 200,"Personal", "14-03-2024"); | ||
transactionList.processTransaction("add /n/Test /$/200 /d/14-03-2024 /c/Personal"); | ||
|
||
assertEquals(1, transactionList.getTransactions().size()); | ||
assertEquals(testTransaction.getDescription(), transactionList.getTransactions().get(0).getDescription()); | ||
assertEquals(testTransaction.getAmount(), transactionList.getTransactions().get(0).getAmount()); | ||
assertEquals(testTransaction.getCategory(), transactionList.getTransactions().get(0).getCategory()); | ||
assertEquals(testTransaction.getDate(), transactionList.getTransactions().get(0).getDate()); | ||
} | ||
} |