diff options
author | Timothée Floure | 2016-05-23 14:32:16 +0200 |
---|---|---|
committer | Timothée Floure | 2016-05-23 14:32:16 +0200 |
commit | 43230122b99b5fd5b60fb9b181cb0bef65104c6b (patch) | |
tree | a3fbda38123137d8808a545a0a19058347a6036f /test/ch | |
parent | 05cfb4a8b3af26d00cbd0c6931ee96a5ad075af2 (diff) | |
download | xblast-43230122b99b5fd5b60fb9b181cb0bef65104c6b.tar.gz |
Basic test for the order of the players to be displayed (client)
Diffstat (limited to 'test/ch')
-rw-r--r-- | test/ch/epfl/xblast/client/PlayerTest.java | 40 |
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 @@ | |||
1 | package ch.epfl.xblast.client; | ||
2 | |||
3 | import ch.epfl.xblast.Lists; | ||
4 | import ch.epfl.xblast.PlayerID; | ||
5 | import ch.epfl.xblast.SubCell; | ||
6 | import org.junit.Assert; | ||
7 | import org.junit.Test; | ||
8 | |||
9 | import java.util.Arrays; | ||
10 | import java.util.List; | ||
11 | |||
12 | /** | ||
13 | * @author Timothée FLOURE (257420) | ||
14 | */ | ||
15 | public 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 | } | ||