Commit 223b80c3 authored by Killian LUCAS's avatar Killian LUCAS
Browse files

GameTest.java update add of several tests

parent 62263f09
......@@ -71,6 +71,8 @@ public class GameTest {
final SurvivalCard vaccin = database.findSurvivalCard(VACCIN.toString());
final SurvivalCard sixieme_sens = database.findSurvivalCard(SIXIEME_SENS.toString());
final SurvivalCard riposte = database.findSurvivalCard(RIPOSTE.toString());
final SurvivalCard hologramme = database.findSurvivalCard(HOLOGRAMME.toString());
final SurvivalCard retraite = database.findSurvivalCard(RETRAITE.toString());
@BeforeEach
public void setUp() {
......@@ -313,6 +315,67 @@ public class GameTest {
.thenReturn(new ActionChoosePower(0));
assertTrue(game.traqueCanResist());
}
@Test
void testPlayerResist_false() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
Response response = new Response(false, "Number must be 1 or 2");
assertEquals(response, game.playerResist(2, 3));
}
@Test
void testPlayerResist_falsePhase2() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
assertEquals(game.getState(), Phase.PREPHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
assertTrue(game.playerPlayCard(2, Collections.singletonList(plage)).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_2).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_2).state);
assertTrue(game.playerPlaceJeton(1, Collections.singletonList(new PlacedJeton(JetonSymbol.CREATURE, Collections.singletonList(Place.PLACE_ONE)))).state);
Response response = new Response(false, "Resist is only possible in PHASE_1");
assertEquals(response, game.playerResist(2, 2));
}
@Test
void testPlayerResist_true() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
assertEquals(game.getState(), Phase.PREPHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
assertTrue(game.playerPlayCard(2, Collections.singletonList(plage)).state);
Response response = new Response(true, "");
assertEquals(response, game.playerResist(2, 2));
}
@Test
void testTraqueCanPickSurvivalCards() throws TException {
......@@ -420,6 +483,75 @@ public class GameTest {
assertTrue(game.creatureCanPlayThisTrackingCards(game.getCreature(), acharnement));
assertTrue(game.creatureCanPlayThisTrackingCards(game.getCreature(), new ArrayList<TrackingCard>(Arrays.asList(acharnement, mutation))));
}
@Test
void testApplyTraquePlaySurvivalCard_true() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
game.getCreature().getTrackingCardHand().clear();
game.getCreature().getTrackingCardHand().add(acharnement);
game.getCreature().getTrackingCardHand().add(mutation);
game.getTraques().get(0).getSurvivalCardsHand().clear();
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens);
board.moveForwardTraque(11);
board.moveForwardCreature(6);
assertEquals(new Score(1, 2), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
game.traquePlaySurvivalCard(game.getTraques().get(0), vaccin);
assertEquals(2,game.getBoard().getScoreCreature());
}
@Test
void testApplyTraquePlaySurvivalCard_false() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
game.getTraques().get(0).getSurvivalCardsHand().clear();
game.getTraques().get(0).getSurvivalCardsHand().add(retraite);
game.getTraques().get(0).getSurvivalCardsHand().add(hologramme);
board.moveForwardTraque(11);
board.moveForwardCreature(6);
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
Response response = new Response(false, "Unable to play this card");
assertEquals(response, game.traquePlaySurvivalCard(game.getTraques().get(0), hologramme));
assertEquals(response, game.traquePlaySurvivalCard(game.getTraques().get(0), new ArrayList<SurvivalCard>(Arrays.asList(hologramme,retraite))));
}
@Test
void testCreaturePlayTrackingCard() throws TException {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
Game game = new Game(a, 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
game.getCreature().getTrackingCardHand().clear();
game.getCreature().getTrackingCardHand().add(acharnement);
game.getCreature().getTrackingCardHand().add(mutation);
game.getTraques().get(0).getSurvivalCardsHand().clear();
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens);
board.moveForwardTraque(11);
board.moveForwardCreature(6);
assertEquals(new Score(1, 2), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
game.traquePlaySurvivalCard(game.getTraques().get(0), vaccin);
assertEquals(2,game.getBoard().getScoreCreature());
}
@Test
......@@ -458,7 +590,7 @@ public class GameTest {
}
}
/*Pour moi
/*Pour moi playerResist
@Test
void testGamePair() throws TException {
Room room = mock(Room.class);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment