From e19c686d888998b9d969647d3d8b06d7a5a3449b Mon Sep 17 00:00:00 2001 From: imanamirshah Date: Thu, 14 Mar 2024 15:23:33 +0800 Subject: [PATCH] Add JUnit test for addItem method in ItemList class --- src/test/java/seedu/binbash/ItemListTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/java/seedu/binbash/ItemListTest.java b/src/test/java/seedu/binbash/ItemListTest.java index d190b6dbbf..d0b512ab1b 100644 --- a/src/test/java/seedu/binbash/ItemListTest.java +++ b/src/test/java/seedu/binbash/ItemListTest.java @@ -15,4 +15,25 @@ void deleteItem_oneItemInItemList_noItemInItemList() { assertEquals(0, itemList.getItemCount()); } + + @Test + void addItem_noItemInItemList_oneItemInItemList() { + ItemList itemList = new ItemList(); + + itemList.addItem("testItem", "A test item"); + assertEquals(1, itemList.getItemCount()); + } + + @Test + void addItem_itemNameAndDescription_correctItemNameAndDescription() { + ItemList itemList = new ItemList(); + + itemList.addItem("testItem", "A test item"); + Item item = itemList.getItemList().get(0); + + assertEquals(item.getItemName(), "testItem"); + assertEquals(item.getItemDescription(), "A test item"); + } + + }