Skip to content
Snippets Groups Projects
Commit 8e075f15 authored by HSoreide's avatar HSoreide
Browse files

Refactor ItemTest class

parent e25c7fd5
No related branches found
No related tags found
1 merge request!3Hs item class
......@@ -10,17 +10,14 @@ class ItemTest {
@Test
@DisplayName("The Item constructor throws exceptions when it should.")
void constructorThrows(){
Exception noCategory = assertThrows(IllegalArgumentException.class, () -> new Item(null, "description", 89.9f));
assertEquals("The item must have a category and a price.", noCategory.getMessage());
Exception noPrice = assertThrows(IllegalArgumentException.class, () -> new Item(ExpenseCategory.OTHER, "description", 0f));
assertEquals("The item must have a category and a price.", noPrice.getMessage());
assertThrows(IllegalArgumentException.class, () -> new Item("description", 89.9f, true));
assertThrows(IllegalArgumentException.class, () -> new Item("description", 0f, false));
};
@Test
@DisplayName("The Item constructor does not throw exceptions when it should not.")
void constructorDoesThrow() {
assertDoesNotThrow(() -> new Item(ExpenseCategory.OTHER, "descriotion", 59.9f));
assertDoesNotThrow(() -> new Item("description", 59.9f, false));
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment