Ejemplo n.º 1
0
        public void SendsVauesInParentAndChildClass()
        {
            var writer = new NetworkWriter();

            writer.WriteMessage(new ChildMessage
            {
                parentValue = 3,
                childValue  = 4
            });

            byte[] arr = writer.ToArray();

            var reader   = new NetworkReader(arr);
            var received = new ChildMessage();

            received.Deserialize(reader);

            Assert.AreEqual(3, received.parentValue);
            Assert.AreEqual(4, received.childValue);

            int writeLength = writer.Length;
            int readLength  = reader.Position;

            Assert.That(writeLength == readLength, $"OnSerializeAll and OnDeserializeAll calls write the same amount of data\n    writeLength={writeLength}\n    readLength={readLength}");
        }
Ejemplo n.º 2
0
        public void Roundtrip()
        {
            var w = new NetworkWriter();

            w.Write(new ChildMessage
            {
                parentValue = 3,
                childValue  = 4
            });

            byte[] arr = w.ToArray();

            var r        = new NetworkReader(arr);
            var received = new ChildMessage();

            received.Deserialize(r);

            Assert.AreEqual(3, received.parentValue);
            Assert.AreEqual(4, received.childValue);
        }