Commit f68cd501 authored by Killian LUCAS's avatar Killian LUCAS
Browse files

GameTest.java update

parent ea27259d
......@@ -13,15 +13,13 @@ import fr.univnantes.alma.server.game.item.jeton.JetonSymbol;
import fr.univnantes.alma.server.game.item.jeton.PlacedJeton;
import fr.univnantes.alma.server.game.item.planet.Place;
import fr.univnantes.alma.server.game.item.planet.Planet;
import fr.univnantes.alma.server.game.utilitary.Pair;
import fr.univnantes.alma.thrift.TAskAction;
import org.apache.thrift.TException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.*;
import static fr.univnantes.alma.server.game.item.card.CardName.*;
import static fr.univnantes.alma.server.game.item.card.CardName.ARTEFACT;
......@@ -73,9 +71,23 @@ public class GameTest {
planet = new Planet(placeCards);
board = new Board(BoardDistribution.FRONT, BoardColor.BLUE);
}
@Test
void testGame() throws TException {
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));
}
@Test
public void testGameCollection_ErrorEmpty(){
Room room = mock(Room.class);
assertThrows(IllegalArgumentException.class,()-> new Game((Collection<Integer>) new ArrayList(), 1, planet, board, room));
}
@Test
public void testGameCollection_ErrorIdCreature(){
Room room = mock(Room.class);
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.getPlanet().forceMovePlanetPawn();
......@@ -131,4 +143,90 @@ public class GameTest {
assertTrue(game.isFinish());
}
@Test
public void testGamePair_ErrorSup7(){
Room room = mock(Room.class);
ArrayList a = new ArrayList();
a.add(new Pair(1,"Natan"));
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((List<Pair<Integer, String>>) a, 1, planet, board, room));
}
@Test
public void testGamePair_ErrorEmpty(){
Room room = mock(Room.class);
assertThrows(IllegalArgumentException.class,()-> new Game((List<Pair<Integer, String>>) new ArrayList(), 1, planet, board, room));
}
@Test
public void testGamePair_ErrorIdCreature(){
Room room = mock(Room.class);
ArrayList a = new ArrayList();
a.add(new Pair(1,"Natan"));
a.add(new Pair(2,"Odile"));
assertThrows(IllegalArgumentException.class,()-> new Game((List<Pair<Integer, String>>) a, 3, planet, board, room));
}
@Test
void testGamePair() throws TException {
Room room = mock(Room.class);
ArrayList a = new ArrayList();
a.add(new Pair(1,"Natan"));
a.add(new Pair(2,"Odile"));
Game game = new Game((List<Pair<Integer, String>>) 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.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());
}
}
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