diff --git a/src/test/java/no/ntnu/idatt1002/demo/data/ExpenseTest.java b/src/test/java/no/ntnu/idatt1002/demo/data/ExpenseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..52387d92cd4a847f4e48a9247faf819916ac2062 --- /dev/null +++ b/src/test/java/no/ntnu/idatt1002/demo/data/ExpenseTest.java @@ -0,0 +1,23 @@ +package no.ntnu.idatt1002.demo.data; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class ExpenseTest { + + @Test + @DisplayName("The Expense constructor throws exceptions when it should.") + void constructorThrows(){ + assertThrows(IllegalArgumentException.class, () -> new Expense("description", 8.5f, false, null)); + assertThrows(IllegalArgumentException.class, () -> new Expense("description", -10.0f, false, ExpenseCategory.BOOKS)); + }; + + @Test + @DisplayName("The Expense constructor does not throw exceptions when it should not.") + void constructorDoesThrow() { + assertDoesNotThrow(() -> new Expense("description", 59.9f, false, ExpenseCategory.BOOKS)); + } + +} \ No newline at end of file diff --git a/src/test/java/no/ntnu/idatt1002/demo/data/IncomeTest.java b/src/test/java/no/ntnu/idatt1002/demo/data/IncomeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..71071f5025cfe1de22f603a62d650e10d52fb3a4 --- /dev/null +++ b/src/test/java/no/ntnu/idatt1002/demo/data/IncomeTest.java @@ -0,0 +1,24 @@ +package no.ntnu.idatt1002.demo.data; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class IncomeTest { + + @Test + @DisplayName("The Income constructor throws exceptions when it should.") + void constructorThrows(){ + assertThrows(IllegalArgumentException.class, () -> new Income("description", 8.5f, false, null)); + assertThrows(IllegalArgumentException.class, () -> new Income("description", -10.0f, false, IncomeCategory.SALARY)); + }; + + @Test + @DisplayName("The Income constructor does not throw exceptions when it should not.") + void constructorDoesThrow() { + assertDoesNotThrow(() -> new Income("description", 59.9f, false, IncomeCategory.SALARY)); + } + + +} \ No newline at end of file diff --git a/src/test/java/no/ntnu/idatt1002/demo/data/ItemTest.java b/src/test/java/no/ntnu/idatt1002/demo/data/ItemTest.java index f9b098b0b8655a834c29e3a9ff8df4a223cc6678..0d3d0a08079fcf768cfb4f42037d1803b56673a7 100644 --- a/src/test/java/no/ntnu/idatt1002/demo/data/ItemTest.java +++ b/src/test/java/no/ntnu/idatt1002/demo/data/ItemTest.java @@ -10,8 +10,8 @@ class ItemTest { @Test @DisplayName("The Item constructor throws exceptions when it should.") void constructorThrows(){ - assertThrows(IllegalArgumentException.class, () -> new Item("description", 89.9f, true)); assertThrows(IllegalArgumentException.class, () -> new Item("description", 0f, false)); + assertThrows(IllegalArgumentException.class, () -> new Item("description", -10.0f, false)); }; @Test