public void TestDecode() { byte[] bytes = { 1, 2, //message PID 3, 4, //message Seq 5, 6, //conv PID 7, 8, //conv Seq 0, 2, //message type 0, 1, //game id 0, 2, //user id 0, 10, 0, 49, 0, 46, 0, 50, 0, 46, 0, 51, //GM address 0, 10, 0, 52, 0, 46, 0, 53, 0, 46, 0, 54 //UA address }; GameInfoMessage gim = GameInfoMessage.Decode(bytes); Assert.AreEqual(gim.GameId, 1); Assert.AreEqual(gim.UserId, 2); Assert.AreEqual(gim.msgId.Pid, 258); Assert.AreEqual(gim.msgId.Seq, 772); Assert.AreEqual(gim.convId.Pid, 1286); Assert.AreEqual(gim.convId.Seq, 1800); Assert.AreEqual(gim.GMAddress, "1.2.3"); Assert.AreEqual(gim.UAAddress, "4.5.6"); }
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"); }