Commit 7453117d authored by Corentin Guillevic's avatar Corentin Guillevic
Browse files

Refactoring of GameTest

parent af1fc563
......@@ -279,70 +279,42 @@ class GameTest {
assertTrue(game.creatureCanPlayThisTrackingCards(game.getCreature(), acharnement));
assertFalse(game.creatureCanPlayThisTrackingCards(game.getCreature(), Arrays.asList(acharnement, mutation)));
game.getTraques().get(0).getSurvivalCardsHand().clear();
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens);
assertTrue(game.traqueCanPlayThisSurvivalCards(game.getTraques().get(0), vaccin));
}
@Test
void testPlayerResist_false() throws TException {
void testPlayerResist_numberPawnWillingnessToLoseGreaterThan2() {
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));
List<Pair<Integer, String>> list = new ArrayList<>(Arrays.asList(new Pair<>(1, "Nathan"), new Pair<>(2, "Odile")));
Game game = new Game(list, 1, planet, board, room);
Response response = new Response(false, "Number must be 1 or 2");
assertEquals(response, game.playerResist(2, 3));
}
@Test
void testPlayerResist_falsePhase2() throws TException {
void testPlayerResist_phase2() {
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);
List<Pair<Integer, String>> list = new ArrayList<>(Arrays.asList(new Pair<>(1, "Nathan"), new Pair<>(2, "Odile")));
Game game = new Game(list, 1, planet, board, room);
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);
//Start phase 1
game.startNextPhase();
//Start postphase 1
game.startNextPhase();
//Start prephase 2
game.startNextPhase();
//Start phase 2
game.startNextPhase();
Response response = new Response(false, "Resist is only possible in PHASE_1");
assertEquals(response, game.playerResist(2, 2));
}
@Test
void testPlayerResist_true() throws TException {
void testPlayerResist_true() {
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);
List<Pair<Integer, String>> list = new ArrayList<>(Arrays.asList(new Pair<>(1, "Nathan"), new Pair<>(2, "Odile")));
Game game = new Game(list, 1, planet, board, room);
//Start phase 1
game.startNextPhase();
Response response = new Response(true, "");
assertEquals(response, game.playerResist(2, 2));
}
......@@ -430,73 +402,26 @@ class GameTest {
assertTrue(game.isFinish());
}
@Test
void testApplyTraquePlaySurvivalCard_true() throws TException {
void testApplyTraquePlaySurvivalCard_true() {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList(Arrays.asList(new Pair(1, "Nathan"), new Pair(2, "Odile")));
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());
int currentCreatureScore = game.getBoard().getScore().getScoreCreature();
assertTrue(game.traquePlaySurvivalCard(game.getTraques().get(0), vaccin).state);
assertEquals(currentCreatureScore+1,game.getBoard().getScoreCreature());
}
@Test
void testApplyTraquePlaySurvivalCard_false() throws TException {
void testApplyTraquePlaySurvivalCard_false() {
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));
List<Pair<Integer, String>> list = new ArrayList<>(Arrays.asList(new Pair<>(1, "Nathan"), new Pair<>(2, "Odile")));
Game game = new Game(list, 1, planet, board, room);
game.getTraques().get(0).getSurvivalCardsHand().addAll(Arrays.asList(retraite, hologramme));
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());
assertEquals(response, game.traquePlaySurvivalCard(game.getTraques().get(0), Arrays.asList(hologramme,retraite)));
}
@Test
......
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