aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ch/epfl/xblast/client/PlayerTest.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/ch/epfl/xblast/client/PlayerTest.java b/test/ch/epfl/xblast/client/PlayerTest.java
new file mode 100644
index 0000000..fdf065e
--- /dev/null
+++ b/test/ch/epfl/xblast/client/PlayerTest.java
@@ -0,0 +1,40 @@
1package ch.epfl.xblast.client;
2
3import ch.epfl.xblast.Lists;
4import ch.epfl.xblast.PlayerID;
5import ch.epfl.xblast.SubCell;
6import org.junit.Assert;
7import org.junit.Test;
8
9import java.util.Arrays;
10import java.util.List;
11
12/**
13 * @author Timothée FLOURE (257420)
14 */
15public class PlayerTest {
16
17 private static final GameState.Player PLAYER_1 = new GameState.Player(PlayerID.PLAYER_1, 5, new SubCell(1,50), null);
18 private static final GameState.Player PLAYER_2 = new GameState.Player(PlayerID.PLAYER_2, 5, new SubCell(20,20), null);
19 private static final GameState.Player PLAYER_3 = new GameState.Player(PlayerID.PLAYER_3, 5, new SubCell(20,20), null);
20 private static final GameState.Player PLAYER_4 = new GameState.Player(PlayerID.PLAYER_4, 5, new SubCell(30,10), null);
21
22 private static final PlayerID CURRENT_PLAYER = PlayerID.PLAYER_3;
23
24
25 @Test
26 public void clientPlayerOder() {
27 List<GameState.Player> players = Arrays.asList(PLAYER_1,PLAYER_2,PLAYER_3,PLAYER_4);
28 List<GameState.Player> expectedOrder = Arrays.asList(PLAYER_4,PLAYER_2,PLAYER_3,PLAYER_1);
29
30 // Order the players
31 List<GameState.Player> computedOrder = Lists.sorted(
32 players,
33 GameState.Player
34 .POSITION_COMPARATOR
35 .thenComparing(GameState.Player.idPushingComparator(CURRENT_PLAYER)));
36
37 // Assert
38 Assert.assertEquals(expectedOrder,computedOrder);
39 }
40}