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

Refactoring of GameTest

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