diff --git a/src/test/java/ActionHandlerTest.java b/src/test/java/ActionHandlerTest.java index 9f92b82..4f29ca9 100644 --- a/src/test/java/ActionHandlerTest.java +++ b/src/test/java/ActionHandlerTest.java @@ -1,3 +1,4 @@ +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.mockito.MockedStatic; import org.mockito.Mockito; @@ -24,6 +25,12 @@ static void initOnce() { gameFrameClass = mockStatic(GameFrame.class); } + @AfterAll + static void afterAll() { + gameClass.close(); + gameFrameClass.close(); + } + @Test void PlayerTurn_hasPoints() { Player player = Mockito.mock(Player.class); diff --git a/src/test/java/BlankFieldTest.java b/src/test/java/BlankFieldTest.java index 9e67a53..17e57f6 100644 --- a/src/test/java/BlankFieldTest.java +++ b/src/test/java/BlankFieldTest.java @@ -1,26 +1,57 @@ import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.mockito.MockedStatic; +import org.mockito.Mockito; class BlankFieldTest { - private BlankField field; + private BlankField blankField; + private static MockedStatic gameClass; + private static MockedStatic gameFrameClass; @BeforeEach public void init() { - this.field = new BlankField(); + this.blankField = new BlankField(); + } + + @BeforeAll + static void initOnce() { + gameClass = Mockito.mockStatic(Game.class); + gameFrameClass = mockStatic(GameFrame.class); + } + + @AfterAll + static void afterAll() { + gameClass.close(); + gameFrameClass.close(); } @Test void GetReferenceID() { - this.field = new BlankField("refID"); + this.blankField = new BlankField("refID"); + + assertEquals("refID", blankField.GetReferenceID()); + } + + @Test + void AcceptWater() { + Field field = mock(Field.class); + + Game game = mock(Game.class); + gameClass.when(Game::Get).thenReturn(game); + + assertTrue(blankField.AcceptWater(field)); - assertEquals("refID", field.GetReferenceID()); + verify(game).InceraseSaboteurPoints(); } @Test void CanAcceptPlayer() { - assertEquals(false, field.CanAcceptPlayer()); + assertEquals(false, blankField.CanAcceptPlayer()); }