public void TestGameInfoMessage() { GameInfoMessage origMessage = new GameInfoMessage(MessageId.Create(), 1, 2, "1.2.3", "4.5.6"); byte[] bytes = origMessage.Encode(); GameInfoMessage decodedMessage = GameInfoMessage.Decode(bytes); Assert.AreEqual(origMessage.MessageType, 2, "Incorrect MessageType"); Assert.AreEqual(origMessage.MessageType, decodedMessage.MessageType, "MessageType did not match"); Assert.AreEqual(origMessage.msgId, decodedMessage.msgId, "msgId did not match"); Assert.AreEqual(origMessage.convId, decodedMessage.convId, "convId did not match"); Assert.AreEqual(origMessage.GameId, decodedMessage.GameId, "GameId did not match"); Assert.AreEqual(origMessage.UserId, decodedMessage.UserId, "UserId did not match"); Assert.AreEqual(origMessage.GMAddress, decodedMessage.GMAddress, "GMAddress did not match"); Assert.AreEqual(origMessage.UAAddress, decodedMessage.UAAddress, "UAAddress did not match"); }
public void TestEncode() { GameInfoMessage gim = new GameInfoMessage(MessageId.Create(), 1, 2, "1.2.3", "4.5.6"); byte[] bytes = gim.Encode(); byte[] messagePIdBytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(gim.msgId.Pid)); byte[] messageSeqBytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(gim.msgId.Seq)); byte[] convPIdBytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(gim.convId.Pid)); byte[] convSeqBytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(gim.convId.Seq)); int currByte = 0; //MessageId //pid Assert.AreEqual(messagePIdBytes[0], bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); Assert.AreEqual(messagePIdBytes[1], bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); //seq Assert.AreEqual(messageSeqBytes[0], bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); Assert.AreEqual(messageSeqBytes[1], bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); //ConversationId //pid Assert.AreEqual(convPIdBytes[0], bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); Assert.AreEqual(convPIdBytes[1], bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); //seq Assert.AreEqual(convSeqBytes[0], bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); Assert.AreEqual(convSeqBytes[1], bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); //short MessageType Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); Assert.AreEqual(2, bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); //short GameId Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); Assert.AreEqual(1, bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); //short UserId Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); Assert.AreEqual(2, bytes[currByte], $"bytes[{currByte++}] did not match asserted value"); //string GMAddress Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(10, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(49, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(46, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(50, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(46, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(51, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); //string UAAddress Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(10, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(52, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(46, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(53, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(46, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(0, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); Assert.AreEqual(54, bytes[currByte], $"bytes[{currByte++}] did note match asserted value"); }