From 43230122b99b5fd5b60fb9b181cb0bef65104c6b Mon Sep 17 00:00:00 2001 From: Timothée Floure Date: Mon, 23 May 2016 14:32:16 +0200 Subject: Basic test for the order of the players to be displayed (client) --- test/ch/epfl/xblast/client/PlayerTest.java | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/ch/epfl/xblast/client/PlayerTest.java 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 @@ +package ch.epfl.xblast.client; + +import ch.epfl.xblast.Lists; +import ch.epfl.xblast.PlayerID; +import ch.epfl.xblast.SubCell; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Arrays; +import java.util.List; + +/** + * @author Timothée FLOURE (257420) + */ +public class PlayerTest { + + private static final GameState.Player PLAYER_1 = new GameState.Player(PlayerID.PLAYER_1, 5, new SubCell(1,50), null); + private static final GameState.Player PLAYER_2 = new GameState.Player(PlayerID.PLAYER_2, 5, new SubCell(20,20), null); + private static final GameState.Player PLAYER_3 = new GameState.Player(PlayerID.PLAYER_3, 5, new SubCell(20,20), null); + private static final GameState.Player PLAYER_4 = new GameState.Player(PlayerID.PLAYER_4, 5, new SubCell(30,10), null); + + private static final PlayerID CURRENT_PLAYER = PlayerID.PLAYER_3; + + + @Test + public void clientPlayerOder() { + List players = Arrays.asList(PLAYER_1,PLAYER_2,PLAYER_3,PLAYER_4); + List expectedOrder = Arrays.asList(PLAYER_4,PLAYER_2,PLAYER_3,PLAYER_1); + + // Order the players + List computedOrder = Lists.sorted( + players, + GameState.Player + .POSITION_COMPARATOR + .thenComparing(GameState.Player.idPushingComparator(CURRENT_PLAYER))); + + // Assert + Assert.assertEquals(expectedOrder,computedOrder); + } +} -- cgit v1.2.3