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]); }
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); }
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); }