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"); } }