public void testSendRequestForPlayer1() { MessageHandler handler = new MOCKMessageHandler(); //Tests valid name and states are correct handler.sendRequest("ID,John"); Assert.AreEqual("PLAYER1", handler.getResponse()); Assert.AreEqual(GameState.WAIT_PLAYER2, handler.getGameState()); Assert.AreEqual("John", handler.getPlayer1Name()); //Can't have any numbers in their name handler = new MOCKMessageHandler(); handler.sendRequest("ID,j0hn"); Assert.AreEqual("ERROR", handler.getResponse()); Assert.AreEqual(GameState.WAIT_PLAYER1, handler.getGameState()); Assert.AreNotEqual("j0hn", handler.getPlayer1Name()); }
public void testSendRequestForMultiplePlayers() { MessageHandler handler = new MOCKMessageHandler(); //Tests can't have same name handler.sendRequest("ID,John"); handler.sendRequest("ID,John"); Assert.AreEqual("ERROR", handler.getResponse()); Assert.AreEqual(GameState.WAIT_PLAYER2, handler.getGameState()); Assert.AreNotEqual("John", handler.getPlayer2Name()); //Can successfully add another name handler.sendRequest("ID,smith"); Assert.AreEqual("PLAYER2", handler.getResponse()); Assert.AreEqual(GameState.PLAYER1_MOVING, handler.getGameState()); Assert.AreEqual("smith", handler.getPlayer2Name()); //Can't add a third name handler.sendRequest("ID,IamNumber3"); Assert.AreEqual("ERROR", handler.getResponse()); }
public void testSendRequestStatus() { MessageHandler handler = new MOCKMessageHandler(); setup2Players(handler); //check in right state and the right player is the current player Assert.AreEqual(GameState.PLAYER1_MOVING, handler.getGameState()); Assert.AreEqual("joy", handler.getCurrentPlayerName()); //Checks that I can get to the status handler.sendRequest("STATUS"); Assert.AreEqual("WAITING", handler.getResponse()); }
public void testSendRequestForUpdate() { MessageHandler handler = new MOCKMessageHandler(); setup2Players(handler); handler.sendRequest("UPDATE"); //check in right state and the right player is the current player Assert.AreEqual(GameState.PLAYER1_MOVING, handler.getGameState()); Assert.AreEqual("joy", handler.getCurrentPlayerName()); //Sees if I can update the board for and get the response string handler.sendRequest("UPDATE"); Assert.AreEqual("N81N74|N12N14N27", handler.getResponse()); }