inventory_mock tests #17
@@ -14,10 +14,6 @@ public record ItemStack(Item item, int quantity) {
|
|||||||
return quantity;
|
return quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSingleItem() {
|
|
||||||
return quantity == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWeight() {
|
public int getWeight() {
|
||||||
return item.getWeight() * quantity;
|
return item.getWeight() * quantity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ public class LootTable<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Unreachable code. entries always have an entry or the class cant be instantiated.
|
// Unreachable code. entries always have an entry or the class cant be instantiated.
|
||||||
|
// Cant put system into this state.
|
||||||
|
// only have a return here due to compiler requiring it.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
src/test/java/BiomeTest.java
Normal file
15
src/test/java/BiomeTest.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import Shared.LootTable;
|
||||||
|
import Terrain.Biome;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
public class BiomeTest {
|
||||||
|
@Test
|
||||||
|
void instantiates_with_name() {
|
||||||
|
var biome = Biome.COAST;
|
||||||
|
|
||||||
|
assertEquals("Coast", biome.getName());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ import Item.BasicItem;
|
|||||||
import Item.ItemStack;
|
import Item.ItemStack;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
@@ -19,9 +21,10 @@ public class ItemStackTest {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void can_be_created_with_positive_quantity() {
|
void can_be_created_with_positive_quantity() {
|
||||||
var i = new ItemStack(new BasicItem("id", "name", 5), 5);
|
var i = new ItemStack(new BasicItem("id", "name", 5), 5);
|
||||||
assertEquals(5, i.getQuantity());
|
assertThat(i, instanceOf(ItemStack.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,13 @@ class PlayerTest {
|
|||||||
assertFalse(p.isAlive());
|
assertFalse(p.isAlive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void is_alive_if_has_health() {
|
||||||
|
var p = defaultPlayer();
|
||||||
|
p.setHealth(10);
|
||||||
|
assertTrue(p.isAlive());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void get_health_returns_health() {
|
void get_health_returns_health() {
|
||||||
var p = defaultPlayer();
|
var p = defaultPlayer();
|
||||||
|
|||||||
Reference in New Issue
Block a user