Commit 8b8a201b authored by Killian LUCAS's avatar Killian LUCAS
Browse files

GameTest.java update pour ce bg qui veut des fonctions, il est si fort

parent fcf9e414
......@@ -63,6 +63,10 @@ public class GameTest {
final PlaceCard fungi = database.findPlaceCard(FUNGI.toString());
final PlaceCard portail = database.findPlaceCard(PORTAIL.toString());
final TrackingCard acharnement = database.findTrackingCard(ACHARNEMENT.toString());
final TrackingCard angoisse = database.findTrackingCard(ANGOISSE.toString());
final TrackingCard mutation = database.findTrackingCard(MUTATION.toString());
final SurvivalCard adrenaline = database.findSurvivalCard(ADRENALINE.toString());
final SurvivalCard alerte = database.findSurvivalCard(ALERTE.toString());
@BeforeEach
public void setUp() {
......@@ -80,31 +84,35 @@ public class GameTest {
planet = new Planet(placeCards);
board = new Board(BoardDistribution.FRONT, BoardColor.BLUE);
}
@Test
public void testGameCollection_ErrorSup7(){
public void testGameCollection_ErrorSup7() {
Room room = mock(Room.class);
assertThrows(IllegalArgumentException.class,()-> new Game(Arrays.asList(1,2,3,4,5,6,7,8), 1, planet, board, room));
assertThrows(IllegalArgumentException.class, () -> new Game(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8), 1, planet, board, room));
}
@Test
public void testGameCollection_ErrorEmpty(){
public void testGameCollection_ErrorEmpty() {
Room room = mock(Room.class);
assertThrows(IllegalArgumentException.class,()-> new Game((Collection<Integer>) new ArrayList(), 1, planet, board, room));
assertThrows(IllegalArgumentException.class, () -> new Game((Collection<Integer>) new ArrayList(), 1, planet, board, room));
}
@Test
public void testGameCollection_ErrorIdCreature(){
public void testGameCollection_ErrorIdCreature() {
Room room = mock(Room.class);
assertThrows(IllegalArgumentException.class,()-> new Game(Arrays.asList(1,2), 3, planet, board, room));
assertThrows(IllegalArgumentException.class, () -> new Game(Arrays.asList(1, 2), 3, planet, board, room));
}
@Test
void testGameCollection() throws TException {
Room room = mock(Room.class);
Game game = new Game(Arrays.asList(1,2), 1, planet, board, room);
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());
assertEquals(new Score(7, 13), board.getScore());
board.moveForwardTraque(11);
board.moveForwardCreature(6);
assertEquals(new Score(1,2), board.getScore());
assertEquals(new Score(1, 2), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
......@@ -153,71 +161,206 @@ public class GameTest {
}
@Test
public void testGamePair_ErrorSup7(){
public void testGamePair_ErrorSup7() {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList();
a.add(new Pair(1,"Nathan"));
a.add(new Pair(2,"Odile"));
a.add(new Pair(3,"Tom tom"));
a.add(new Pair(4,"Alban"));
a.add(new Pair(5,"Luna"));
a.add(new Pair(6,"Oriane"));
a.add(new Pair(7,"Nana"));
a.add(new Pair(8,"Emilie"));
assertThrows(IllegalArgumentException.class,()-> new Game( a, 1, planet, board, room));
a.add(new Pair(1, "Nathan"));
a.add(new Pair(2, "Odile"));
a.add(new Pair(3, "Tom tom"));
a.add(new Pair(4, "Alban"));
a.add(new Pair(5, "Luna"));
a.add(new Pair(6, "Oriane"));
a.add(new Pair(7, "Nana"));
a.add(new Pair(8, "Emilie"));
assertThrows(IllegalArgumentException.class, () -> new Game(a, 1, planet, board, room));
}
@Test
public void testGamePair_ErrorEmpty(){
public void testGamePair_ErrorEmpty() {
Room room = mock(Room.class);
assertThrows(IllegalArgumentException.class,()-> new Game((List<Pair<Integer, String>>) new ArrayList(), 1, planet, board, room));
assertThrows(IllegalArgumentException.class, () -> new Game((List<Pair<Integer, String>>) new ArrayList(), 1, planet, board, room));
}
@Test
public void testGamePair_ErrorIdCreature(){
public void testGamePair_ErrorIdCreature() {
Room room = mock(Room.class);
List<Pair<Integer, String>> a = new ArrayList();
a.add(new Pair(1,"Nathan"));
a.add(new Pair(2,"Odile"));
assertThrows(IllegalArgumentException.class,()-> new Game( a, 3, planet, board, room));
a.add(new Pair(1, "Nathan"));
a.add(new Pair(2, "Odile"));
assertThrows(IllegalArgumentException.class, () -> new Game(a, 3, planet, board, room));
}
@Test
void testGamePair() 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);
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());
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));
}
@Test
void testEnableAndDisableJetonArtemia() 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();
// verification jetonArtemia
assertTrue(game.isJetonArtemiaIsActive());
game.disableJetonArtemia();
assertFalse(game.isJetonArtemiaIsActive());
game.enableJetonArtemia();
assertTrue(game.isJetonArtemiaIsActive());
}
@Test
void testGetCreature() 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();
// verification creature
assertEquals(1,game.getCreature().getInGameId());
assertEquals(1, game.getCreature().getInGameId());
}
@Test
void testGetTraque() 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();
// verification traque
assertEquals("Odile",game.getTraques().get(0).getName());
//verifcation getPlayerMap
assertEquals( 2,game.getPlayersMap().size());
//verifcation getPlayer
assertEquals("Player1",game.getPlayer(1).getName());
assertEquals("Odile", game.getTraques().get(0).getName());
}
@Test
void testGetPlayerMap() 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();
//verification getPlayerMap
assertEquals(2, game.getPlayersMap().size());
}
@Test
void testGetPlayer() 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();
//verification getPlayer
assertEquals("Player1", game.getPlayer(1).getName());
}
@Test
void testGetRoom() 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();
//verification room
assertSame(game.getRoom(),game.getRoom());
assertSame(game.getRoom(), game.getRoom());
}
@Test
void testGetReserve() 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();
//verification reserve
assertEquals(new Reserve(new ArrayList<PlaceCard>(Arrays.asList(marais,abri,epave,source,artefact)),2).getPlaceCards(),game.getReserve().getPlaceCards());
assertEquals(new Score(7,13), board.getScore());
assertEquals(new Reserve(new ArrayList<PlaceCard>(Arrays.asList(marais, abri, epave, source, artefact)), 2).getPlaceCards(), game.getReserve().getPlaceCards());
}
@Test
void testTraqueCanResist() 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());
board.moveForwardTraque(11);
board.moveForwardCreature(6);
assertEquals(new Score(1,2), board.getScore());
assertEquals(new Score(1, 2), board.getScore());
when(room.askAction(any(Integer.class), any(TAskAction.class)))
.thenReturn(new ActionChoosePower(0));
/* test for traque */
assertTrue(game.traqueCanResist());
}
@Test
void testTraqueCanPickSurvivalCards() 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());
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.traqueCanPickSurvivalCards());
}
@Test
void testCreaturePlayTrackingCard_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);
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));
/*test creaturePlayTrackingCard*/
Response response2 = new Response(false, "Unable to play this card");
assertEquals(response2,game.creaturePlayTrackingCard(game.getCreature(), acharnement));
assertEquals(response2, game.creaturePlayTrackingCard(game.getCreature(), acharnement));
}
@Test
void testCanPlayMethods_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());
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));
assertEquals(game.getState(), Phase.PREPHASE_1);
......@@ -226,34 +369,119 @@ public class GameTest {
assertEquals(game.getState(), Phase.PHASE_1);
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 can play between 2 phases -> false */
assertFalse(game.creatureCanPlayThisTrackingCards(game.getCreature(), new ArrayList<TrackingCard>(Arrays.asList(acharnement, angoisse))));
assertFalse(game.traqueCanPlayThisSurvivalCards(game.getTraques().get(0), new ArrayList<SurvivalCard>(Arrays.asList(alerte, adrenaline))));
assertFalse(game.traqueCanPlayThisSurvivalCards(game.getTraques().get(0), alerte));
assertFalse(game.creatureCanPlayThisTrackingCards(game.getCreature(), acharnement));
}
/* @Test
void testCanPlayMethods_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();
/*Response response1 = new Response(true, "");
assertEquals(response1,game.playerPlayCard(2, riviere));*/
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));
assertEquals(game.getState(), Phase.PREPHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertEquals(game.getState(), Phase.PHASE_1);
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.creatureCanPlayThisTrackingCards(game.getCreature(), acharnement));
}*/
@Test
void testPlayerPlayCard() 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());
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));
assertEquals(game.getState(), Phase.PREPHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertEquals(game.getState(), Phase.PHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
assertTrue(game.playerPlayCard(2, Collections.singletonList(plage)).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_1).state);
assertFalse(game.playerHasFinished(2, Phase.POSTPHASE_2).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);
/*test playerPlayCard*/
Response response = new Response(false, "No card authorize in this phase");
assertEquals(response, game.playerPlayCard(2, riviere));
}
}
/*Pour moi
@Test
void testGamePair() 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();
assertFalse(game.playerHasFinished(1, Phase.PHASE_2).state);
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));
assertEquals(game.getState(), Phase.PREPHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertEquals(game.getState(), Phase.PHASE_1);
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);
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);
......@@ -274,4 +502,4 @@ public class GameTest {
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