Commit 000a01d9 authored by Corentin Guillevic's avatar Corentin Guillevic
Browse files

Refactoring of GameTest

parent 67b7d9ff
......@@ -9,7 +9,6 @@ import fr.univnantes.alma.server.game.item.board.Board;
import fr.univnantes.alma.server.game.item.board.BoardColor;
import fr.univnantes.alma.server.game.item.board.BoardDistribution;
import fr.univnantes.alma.server.game.item.board.Score;
import fr.univnantes.alma.server.game.item.card.Card;
import fr.univnantes.alma.server.game.item.card.PlaceCard;
import fr.univnantes.alma.server.game.item.card.SurvivalCard;
import fr.univnantes.alma.server.game.item.card.TrackingCard;
......@@ -346,62 +345,6 @@ class GameTest {
assertEquals(response, game.playerPlayCard(2, riviere));
}
@Test
void testGameScenario() throws TException {
Room room = mock(Room.class);
Game game = new Game(Arrays.asList(1, 2), 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore());
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));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
assertFalse(game.playerHasFinished(2, 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);
assertFalse(game.playerHasFinished(1, Phase.PHASE_2).state);
assertTrue(game.playerPlaceJeton(1, Collections.singletonList(new PlacedJeton(JetonSymbol.CREATURE, Collections.singletonList(Place.PLACE_ONE)))).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_2).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_2).state);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_2).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_2).state);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_3).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_3).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_3).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_3).state);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_3).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_3).state);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_4).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_4).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_4).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_4).state);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_4).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_4).state);
assertTrue(game.isFinish());
}
@Test
void testApplyTraquePlaySurvivalCard_true() {
Room room = mock(Room.class);
......@@ -440,141 +383,121 @@ class GameTest {
}
@Test
void testPlayerPlayCard_sendErrorMessage2() throws TException {
void testPlayerPlayCard_traquePlaySurvivalCardInPhase1() {
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());
game.getTraques().get(0).getSurvivalCardsHand().clear();
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().add(vaccin);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens);
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
//Start phase1
game.startNextPhase();
Response response = new Response(false, "Need a place card");
assertEquals(response,game.playerPlayCard(2, vaccin));
}
@Test
void testPlayerPlayCard_sendErrorMessage3() throws TException {
void testPlayerPlayCard_creaturePlayTrackingCardInPhase1() {
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());
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.getCreature().getTrackingCardHand().clear();
game.getCreature().getTrackingCardHand().add(acharnement);
game.getCreature().getTrackingCardHand().add(mutation);
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
game.getCreature().getTrackingCardHand().addAll(Arrays.asList(acharnement, mutation));
//Start phase1
game.startNextPhase();
Response response = new Response(false, "No card authorize in this phase");
assertEquals(response,game.playerPlayCard(1, acharnement));
}
}@Test
void testPlayerPlayCard_true() throws TException {
@Test
void testPlayerPlayCard_traquePlayPlaceCardInPhase1() {
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));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, 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);
//Start phase1
game.startNextPhase();
Response response = new Response(true, "");
assertEquals(response,game.playerPlayCard(2, plage));
assertTrue(game.playerHasFinished(2, Phase.PHASE_1).state);
}
@Test
void testPlayerPlayCardList_traquePlaySurvivalAndPlaceCardInPhase1() {
Room room = mock(Room.class);
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 phase1
game.startNextPhase();
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin);
Response response = new Response(false, "Need only place card");
assertEquals(response,game.playerPlayCard(2, Arrays.asList(plage,vaccin)));
}
@Test
void testPlayerPlayCardList_sendErrorMessage() throws TException {
void testTraquePlayPlaceCard_traquePlaceTwoPlaceCard() {
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);
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 phase1
game.startNextPhase();
game.traquePlayPlaceCard(game.getTraques().get(0), plage);
Response response = new Response(false, "Unable to play this card");
assertEquals(response,game.traquePlayPlaceCard(game.getTraques().get(0), riviere));
}
@Test
void testGameScenario() throws TException {
Room room = mock(Room.class);
Game game = new Game(Arrays.asList(1, 2), 1, planet, board, room);
game.getPlanet().forceMovePlanetPawn();
Board board = game.getBoard();
assertEquals(new Score(7, 13), board.getScore());
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));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
Response response = new Response(false, "Need only place card");
assertEquals(response,game.playerPlayCard(2, new ArrayList(Arrays.asList(plage,vaccin))));
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
assertFalse(game.playerHasFinished(2, Phase.PHASE_1).state);
assertTrue(game.playerPlayCard(2, Collections.singletonList(plage)).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_1).state);
}
@Test
void testTraquePlayPlaceCard_sendErrorMessage() 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);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_1).state);
assertEquals(new Score(7, 13), board.getScore());
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_2).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_2).state);
assertFalse(game.playerHasFinished(1, Phase.PHASE_2).state);
assertTrue(game.playerPlaceJeton(1, Collections.singletonList(new PlacedJeton(JetonSymbol.CREATURE, Collections.singletonList(Place.PLACE_ONE)))).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_2).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_2).state);
game.getTraques().get(0).getSurvivalCardsHand().clear();
game.getTraques().get(0).getSurvivalCardsHand().add(vaccin);
game.getTraques().get(0).getSurvivalCardsHand().add(sixieme_sens);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_2).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_2).state);
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_3).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_3).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_3).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_3).state);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_3).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_3).state);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
Response response = new Response(false, "Unable to play this card");
game.traquePlayPlaceCard(game.getTraques().get(0), plage);
assertEquals(response,game.traquePlayPlaceCard(game.getTraques().get(0), riviere));
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_4).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_4).state);
assertTrue(game.playerHasFinished(1, Phase.PHASE_4).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_4).state);
assertTrue(game.playerHasFinished(1, Phase.POSTPHASE_4).state);
assertTrue(game.playerHasFinished(2, Phase.POSTPHASE_4).state);
assertTrue(game.isFinish());
}
}
......
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