-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTigerZoneServerProtocolTest.java
55 lines (52 loc) · 2.09 KB
/
TigerZoneServerProtocolTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import static org.junit.Assert.*;
import org.junit.Test;
public class TigerZoneServerProtocolTest {
@Test
public void testAuthenticationProtocol(){
TigerZoneProtocol tzProtocol = new TigerZoneProtocol();
String tournamentPassword = null;
String sparta = tzProtocol.VerifyAuthentication(tournamentPassword);
assertEquals("THIS IS SPARTA!", sparta);
tournamentPassword = "JOIN PersiaRocks!";
String hello = tzProtocol.VerifyAuthentication(tournamentPassword);
assertEquals("HELLO!", hello);
}
@Test
public void testAuthenticationFailure(){
TigerZoneProtocol tzProtocol = new TigerZoneProtocol();
String tournamentPassword = null;
String sparta = tzProtocol.VerifyAuthentication(tournamentPassword);
assertEquals("THIS IS SPARTA!", sparta);
tournamentPassword = "JOIN ILikeCats!";
String wrong = tzProtocol.VerifyAuthentication(tournamentPassword);
assertEquals("Wrong password, try \"PersiaRocks!\"! ", wrong);
}
@Test
public void testStartGame(){
TigerZoneProtocol tzProtocol = new TigerZoneProtocol();
String getTiles = tzProtocol.StartGame();
String[] remainingTiles = getTiles.split(" ");
assertEquals("76", remainingTiles[2]);
}
@Test
public void testNotifyPlayer(){
TigerZoneProtocol tzProtocol = new TigerZoneProtocol();
String notification = tzProtocol.NotifyPlayer();
String expected = "MAKE YOUR MOVE IN GAME C WITHIN 1 SECOND: MOVE 1 PLACE JJJJ-";
assertEquals(expected, notification);
}
@Test
public void testSendGameAMove(){
TigerZoneProtocol tzProtocol = new TigerZoneProtocol();
String gameAMove = tzProtocol.SendGameAMove("GAME C MOVE 1 PLACE JJJJ- AT 1 1 90 TIGER 5");
String expected = "GAME C MOVE 1 PLAYER Red PLACED JJJJ- AT 1 1 90 TIGER 5";
assertEquals(expected, gameAMove);
}
@Test
public void testSendGameBMove(){
TigerZoneProtocol tzProtocol = new TigerZoneProtocol();
String gameBMove = tzProtocol.SendGameBMove("GAME D MOVE 1 PLACE JJJJ- AT 1 1 90 TIGER 5");
String expected = "GAME D MOVE 1 PLAYER Blue PLACED JJJJ- AT 1 1 90 TIGER 5";
assertEquals(expected, gameBMove);
}
}