public void TestCreateGameConv() { IPEndPoint ip = new IPEndPoint(IPAddress.Any, 0); CreateGameConv conv = ConversationFactory .Instance.CreateFromConversationType <CreateGameConv> (ip, null, null, null); conv._MinPlayers = 5; conv._MaxPlayers = 6; CreateGame msg = (CreateGame)conv.CreateFirstMessage(); Assert.AreEqual(msg.MaxPlayers, 6); Assert.AreEqual(msg.MinPlayers, 5); CommSubSystem.ConversationQueue queue = conv.MyQueue; queue.Enqueue(msg.Encode()); conv.Receive(); Assert.AreEqual(conv.Error, null); Assert.AreEqual(conv.incomingMsg, msg.Encode()); Assert.AreEqual(true, conv.ValidateEnvelope(msg)); }
public void EncodeAndDecode_CreateGame() { MessageId msgId = new MessageId(); MessageId convId = new MessageId(); CreateGame msg1 = new CreateGame() { MsgId = msgId, ConvId = convId, MinPlayers = 1, MaxPlayers = 5 }; byte[] bytes = msg1.Encode(); CreateGame msg2 = Message.Decode <CreateGame>(bytes); Assert.IsNotNull(msg2); Assert.AreEqual(msg1.MsgId, msg2.MsgId); Assert.AreEqual(msg1.ConvId, msg2.ConvId); Assert.AreEqual(msg1.MinPlayers, msg2.MinPlayers); Assert.AreEqual(msg1.MaxPlayers, msg2.MaxPlayers); }