Exemplo n.º 1
0
        public void ClientReceiveMultiMessageTest()
        {
            var stream = new MemoryStreamThreadSafeSeek();
            var writer = new StreamWriter(stream);

            var client = new MuClient(stream);
            List <NetworkMsg> rcvdMsg = new List <NetworkMsg>();

            client.MsgReceived += (s, e) => rcvdMsg.Add(e.Msg);

            var msg = new FakeNetworkMsg()
            {
                Content = "ReceiveTest"
            };
            var emptyMsg = new FakeNetworkMsg()
            {
                Content = ""
            };

            writer.WriteAndRewind(msg.Serialize());
            writer.WriteAndRewind(emptyMsg.Serialize());
            writer.WriteAndRewind(msg.Serialize());

            Thread.Sleep(220);
            Assert.AreEqual(msg, rcvdMsg[0]);
            Assert.AreEqual(emptyMsg, rcvdMsg[1]);
            Assert.AreEqual(msg, rcvdMsg[2]);
        }
Exemplo n.º 2
0
        public void ClientSendMessageTest()
        {
            var stream = new MemoryStreamThreadSafeSeek();
            var reader = new StreamReader(stream);

            var client = new MuClient(stream);

            var msg = new FakeNetworkMsg()
            {
                Content = "SendTest"
            };

            client.SendMessage(msg);

            var recvdMsg = reader.ReadToEnd();

            Assert.AreEqual(msg.Serialize(), recvdMsg);
        }
Exemplo n.º 3
0
        public void ClientReceiveMessageTest()
        {
            var stream = new MemoryStreamThreadSafeSeek();
            var writer = new StreamWriter(stream);

            var        client  = new MuClient(stream);
            NetworkMsg rcvdMsg = null;

            client.MsgReceived += (s, e) => rcvdMsg = e.Msg;

            var msg = new FakeNetworkMsg()
            {
                Content = "ReceiveTest"
            };

            writer.WriteAndRewind(msg.Serialize());
            Thread.Sleep(110);
            Assert.AreEqual(msg, rcvdMsg);
        }