Example #1
0
        public void TestVectorTypedObject()
        {
            var writer = new Amf3Writer();
            var reader = new Amf3Reader();

            reader.RegisterTypedObject <TestCls>();

            var t = new TestCls()
            {
                T1 = 3.3,
                T2 = "abc",
                T3 = "abd",
                t4 = new Vector <int>()
                {
                    2000, 30000, 400000
                }
            };

            t.AddDynamic("t5", new Vector <TestCls>()
            {
                new TestCls {
                    T1 = 5.6
                }
            });

            using (var sc = new SerializationContext())
            {
                var v = new Vector <TestCls>()
                {
                    t, t, t
                };
                writer.WriteBytes(v, sc);
                var buffer = new byte[sc.MessageLength];
                sc.GetMessage(buffer);

                reader.TryGetVectorObject(buffer, out var readVal, out var consumed);
                Assert.IsTrue(readVal.GetType().GetGenericArguments().First() == typeof(TestCls));
                Assert.AreEqual(v, readVal);
                Assert.AreEqual(buffer.Length, consumed);
            }
        }