Skip to content

Commit

Permalink
worked on BlankFieldTest and fixed ActionHandlerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
bertalanaron committed May 16, 2024
1 parent 34281d1 commit 031b2b6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/test/java/ActionHandlerTest.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
Expand All @@ -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);
Expand Down
41 changes: 36 additions & 5 deletions src/test/java/BlankFieldTest.java
Original file line number Diff line number Diff line change
@@ -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<Game> gameClass;
private static MockedStatic<GameFrame> 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());
}


Expand Down

0 comments on commit 031b2b6

Please sign in to comment.