Ejemplo n.º 1
0
        public void TestConnect()
        {
            var packet = new RequestPacket("connect");

            packet.DataPacket["name"]    = "Edoardo";
            packet.DataPacket["surname"] = "Fullin";
            packet.DataPacket["pcname"]  = "EDO-PC";

            Debug.WriteLine(packet.Serialize());
            Assert.IsTrue(packet.Serialize() == "{\"request\":\"connect\",\"dataPacket\":{\"name\":\"Edoardo\",\"surname\":\"Fullin\",\"pcname\":\"EDO-PC\"}}");
        }
        private void Serialization(ISerializer serializer)
        {
            var req = new RequestPacket("asdf");

            using (var ms = new MemoryStream())
                using (var writer = new BinaryWriter(ms, Encoding.Default, true))
                    using (var reader = new BinaryReader(ms, Encoding.Default, true)) {
                        req.Serialize(writer, serializer);

                        ms.Position = 0;

                        var r2 = new RequestPacket("name");
                        r2.Deserialize(reader, serializer);

                        Assert.AreEqual(req.Name, r2.Name);
                    }
        }