inventory_mock tests #17

Merged
erns6604 merged 16 commits from inventory_mocks into main 2025-10-30 07:52:55 +01:00
Showing only changes of commit 0c5de2518d - Show all commits

View File

@@ -0,0 +1,27 @@
import Item.BasicItem;
import Item.ItemStack;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class ItemStackTest {
@Test
void instantiated_with_no_quantity_throws_exception() {
assertThrows(IllegalArgumentException.class, () -> new ItemStack(
new BasicItem("id", "name", 5), 0
));
}
@Test
void instantiated_with_negative_quantity_throws_exception() {
assertThrows(IllegalArgumentException.class, () -> new ItemStack(
new BasicItem("id", "name", 5), -4
));
}
@Test
void can_be_created_with_positive_quantity() {
var i = new ItemStack(new BasicItem("id", "name", 5), 5);
assertEquals(5, i.getQuantity());
}
}