package de.fhdw.gaming.ipspiel23.c4.gststrategy;
import static org.junit.jupiter.api.Assertions.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import de.fhdw.gaming.core.domain.GameException;
import de.fhdw.gaming.ipspiel23.c4.domain.IC4Game;
import de.fhdw.gaming.ipspiel23.c4.domain.IC4GameBuilder;
import de.fhdw.gaming.ipspiel23.c4.domain.IC4Player;
import de.fhdw.gaming.ipspiel23.c4.domain.IC4PlayerBuilder;
import de.fhdw.gaming.ipspiel23.c4.domain.IC4State;
import de.fhdw.gaming.ipspiel23.c4.domain.impl.C4GameBuilder;
import de.fhdw.gaming.ipspiel23.c4.domain.impl.C4Position;
import de.fhdw.gaming.ipspiel23.c4.moves.IC4Move;
import de.fhdw.gaming.ipspiel23.c4.moves.factory.IC4MoveFactory;
import de.fhdw.gaming.ipspiel23.c4.moves.impl.C4DefaultMoveFactory;
import de.fhdw.gaming.ipspiel23.c4.strategies.IC4Strategy;
import de.fhdw.gaming.ipspiel23.c4.strategies.IC4StrategyFactory;
/**
* Tests the C4GSTStrategy.
*/
class C4GSTStrategyTest {
/**
* Game for tests.
*/
private IC4Game game;
/**
* MoveFactory for tests.
*/
private IC4MoveFactory moveFactory;
/**
* First player for tests.
*/
private IC4Player playerA;
/**
* Second player for tests.
*/
private IC4Player playerB;
/**
* Players strategy.
*/
private IC4Strategy strategy;
/**
* Creates an empty game.
*
* @throws GameException
* @throws InterruptedException
*/
@BeforeEach
void gameSetup() throws GameException, InterruptedException {
final IC4GameBuilder gb = new C4GameBuilder();
gb.changeBoardColumns(7);
gb.changeBoardRows(6);
final IC4PlayerBuilder pbA = gb.createPlayerBuilder();
final IC4PlayerBuilder pbB = gb.createPlayerBuilder();
pbA.changeName("A");
this.playerA = pbA.build();
pbB.changeName("B");
this.playerB = pbB.build();
this.moveFactory = new C4DefaultMoveFactory();
final IC4StrategyFactory strategyFactory = new C4GSTMoveStrategyFactory();
this.strategy = strategyFactory.create(moveFactory);
gb.addPlayer(playerA, strategy);
gb.addPlayer(playerB, strategy);
this.game = gb.build(0);
}
/**
* This Test ensures the correct name is given by toString.
*/
@Test
public void testStrategyName() {
final String expectedName = "C4GSTMoveStrategy";
assertEquals(expectedName, strategy.toString());
}
JUnit 5 tests should be package-private.
Reports JUnit 5 test classes and methods that are not package-private.
Contrary to JUnit 4 tests, which required public visibility to be run by the engine,
JUnit 5 tests can also be run if they're package-private. Marking them as such
is a good practice to limit their visibility.
Test methods are identified as those which use `@Test`, `@RepeatedTest`,
`@TestFactory`, `@TestTemplate` or `@ParameterizedTest`.
class MyTest { // not public, that's fine
@Test
public void testBad() { } // should not have a public modifier
@Test
protected void testAlsoBad() { } // should not have a protected modifier
@Test
private void testNoRun() { } // should not have a private modifier
@Test
void testGood() { } // package private as expected
}