inventory_mock tests #17
27
src/test/java/ItemStackTest.java
Normal file
27
src/test/java/ItemStackTest.java
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user