public void ReadCharTest()
        {
            // GIVEN a buffer of serialized data
            mockMessageBuffer.Setup(m => m.Buffer).Returns(new byte[] { 0, 0, 0, 2, 65, 0 });
            mockMessageBuffer.Setup(m => m.Offset).Returns(0);
            mockMessageBuffer.Setup(m => m.Count).Returns(6);

            // WHEN I read a char from the reader
            char result = reader.ReadChar();

            // THEN the value is as expected
            Assert.AreEqual('A', result);
        }
        private void ClientMessageReceived(object sender, MessageReceivedEventArgs e)
        {
            using (Message message = e.GetMessage())
                using (DarkRiftReader reader = message.GetReader())
                {
                    if (message.Tag == (ushort)ChessEnums.MessageTags.PlayerReady)
                    {
                        if (reader.Length % 2 != 0)
                        {
                            Logger.Error("Received malformed ready packet.");
                            return;
                        }
                        ushort id = reader.ReadUInt16();
                        Logger.Log("Player Ready: " + id, LogType.Info);
                        readyPlayers.Add(id);
                        if (readyPlayers.Count == 2)
                        {
                            DeliverColorsAndStartGame();
                        }
                    }
                    else if (message.Tag == (ushort)ChessEnums.MessageTags.MovePiece)
                    {
                        char originColumn = reader.ReadChar();
                        char originRow    = reader.ReadChar();
                        char targetColumn = reader.ReadChar();
                        char targetRow    = reader.ReadChar();
                        SendMovementToClient(originColumn, originRow, targetColumn, targetRow, ClientManager.GetClient(ingamePlayers.Find(x => x != e.Client.ID)).ID);

                        if (playerColors[e.Client.ID] == ChessEnums.Colors.White)
                        {
                            timer.WhiteMoved();
                        }
                        else
                        {
                            timer.BlackMoved();
                        }
                    }
                    else if (message.Tag == (ushort)ChessEnums.MessageTags.PieceEaten)
                    {
                        char column = reader.ReadChar();
                        char row    = reader.ReadChar();
                        Logger.Log("Eaten: " + column + row, LogType.Info);
                        SendEatenPieceToClient(column, row, ClientManager.GetClient(ingamePlayers.Find(x => x != e.Client.ID)).ID);
                    }
                    else if (message.Tag == (ushort)ChessEnums.MessageTags.WinnerMessage)
                    {
                        timer.EndTimer(reader.ReadBoolean());
                    }
                    else if (message.Tag == (ushort)ChessEnums.MessageTags.MoveReplace)
                    {
                        char   originColumn = reader.ReadChar();
                        char   originRow    = reader.ReadChar();
                        char   targetColumn = reader.ReadChar();
                        char   targetRow    = reader.ReadChar();
                        ushort type         = reader.ReadUInt16();
                        SendMovementReplaceToClient(originColumn, originRow, targetColumn, targetRow, type, ClientManager.GetClient(ingamePlayers.Find(x => x != e.Client.ID)).ID);
                        if (playerColors[e.Client.ID] == ChessEnums.Colors.White)
                        {
                            timer.WhiteMoved();
                        }
                        else
                        {
                            timer.BlackMoved();
                        }
                    }
                }
        }