Ejemplo n.º 1
0
        public void TestTypedObject()
        {
            var writer = new Amf0Writer();
            var reader = new Amf0Reader();

            reader.RegisterType <TypedClass>();

            object nullVal = null;
            var    refVal  = new List <object>()
            {
                1, 2, "test"
            };

            var obj = new TypedClass()
            {
                c     = 1.0,
                test  = false,
                test2 = nullVal,
                test3 = new Undefined(),
                test4 = refVal,
                test5 = "test",
                test6 = refVal
            };

            using (var sc = new SerializationContext())
            {
                writer.WriteTypedBytes(obj, sc);
                var buffer = new byte[sc.MessageLength];
                sc.GetMessage(buffer);

                Assert.IsTrue(reader.TryGetTypedObject(buffer, out var readObj, out var consumed));
                Assert.AreEqual(consumed, buffer.Length);
            }
        }
Ejemplo n.º 2
0
        public void TestPacket()
        {
            var reader = new Amf0Reader();

            reader.RegisterType <RemotingMessage>();
            reader.StrictMode = false;
            using (var file = new FileStream("../../../../samples/amf0/misc/packet.amf0", FileMode.Open))
            {
                var data = new byte[file.Length];
                file.Read(data);
                Assert.IsTrue(reader.TryGetPacket(data, out var headers, out var messages, out var consumed));
                Assert.AreEqual(consumed, file.Length);
            }
        }