diff --git a/src/test/java/uulm/teamname/marvelous/gamelibrary/TupleTest.java b/src/test/java/uulm/teamname/marvelous/gamelibrary/TupleTest.java index 8452bf0..4adf83e 100644 --- a/src/test/java/uulm/teamname/marvelous/gamelibrary/TupleTest.java +++ b/src/test/java/uulm/teamname/marvelous/gamelibrary/TupleTest.java @@ -1,14 +1,13 @@ package uulm.teamname.marvelous.gamelibrary; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; class TupleTest { @Test - void basic() { - var a = new Tuple(0, 1); + void basicTest() { + Tuple a = new Tuple<>(0, 1); assertEquals((int) a.item1, 0); assertEquals((int) a.item2, 1); } diff --git a/src/test/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameStateTest.java b/src/test/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameStateTest.java new file mode 100644 index 0000000..d7a78fc --- /dev/null +++ b/src/test/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameStateTest.java @@ -0,0 +1,35 @@ +package uulm.teamname.marvelous.gamelibrary.gamelogic; + +import org.junit.jupiter.api.Test; +import uulm.teamname.marvelous.gamelibrary.IntVector2; +import uulm.teamname.marvelous.gamelibrary.entities.EntityID; +import uulm.teamname.marvelous.gamelibrary.entities.EntityType; +import uulm.teamname.marvelous.gamelibrary.entities.Rock; + +import static org.junit.jupiter.api.Assertions.*; + +class GameStateTest { + @Test + void testSnapshot() { + //TODO: test all properties in GameStateTest.testSnapshot + + //base state + GameState state = new GameState(new IntVector2(10, 10)); + + //set up game + state.entities.addEntity(new Rock(new EntityID(0, EntityType.Rocks), new IntVector2(0, 0), 100)); + + //snapshot state + GameState snapshot = state.snapshot(); + + //modify snapshot and test for disconnection + + snapshot.turnNumber = 10; + assertEquals(0, state.turnNumber, "Original's turn number should remain unchanged"); + + assertTrue(snapshot.entities.getEntities().hasNext(), "Snapshot should contain cloned entities"); + + ((Rock)snapshot.entities.getEntities().next()).decreaseHp(5); + assertEquals(100, ((Rock)state.entities.getEntities().next()).getHp(), "Original's rock entity hp should remain unchanged"); + } +}