Esempio n. 1
0
        public async Task Test_Array_Ctor_Object_Buffer(int len)
        {
            BinarySerializerOptions options = new BinarySerializerOptions()
            {
                DefaultBufferSize = 1
            };

            TestCtorA[] a1 = new TestCtorA[]
            {
                new TestCtorB(new string('A', len), 1),
                createComplexCtorC(len),
                createComplexCtorC(len),
                null,
                createComplexCtorC(len),
                null
            };

            TestArrayCtorObj obj = new TestArrayCtorObj(a1);


            await Test(obj, b =>
            {
                CheckIEnumerable(obj.A, (a, b) => checkCtorCProc(a)(b));
            }, options);
        }
Esempio n. 2
0
        public async Task Test_Larg_Object_Ctor()
        {
            TestCtorB b = new TestCtorB("B", 1);

            b.C = "C";
            TestCtorA a = new TestCtorA("A", 1);

            TestCtorC c = new TestCtorC(b, a);

            await Test <TestCtorC>(c, checkCtorCProc(c), largCtorOptions);

            b.TestA = new ObjTestB()
            {
                A = 1,
                D = new ObjTestB()
                {
                    A = 1,
                    B = "B",
                    D = new ObjTestA()
                    {
                        A = 2
                    }
                },
                E = 1,
                C = new ObjTestB()
                {
                    A = 1,
                    B = "B"
                }
            };

            await Test <TestCtorC>(c, checkCtorCProc(c), largCtorOptions);
        }
        public async Task Test_IDictionary_Dictionary_Complex_Buffer(int len)
        {
            Dictionary <TestCtorA, TestCtorA> a = new Dictionary <TestCtorA, TestCtorA>();

            var key1 = createComplexCtorC(len);

            key1.B = 1;

            a.Add(key1, createComplexCtorC(len));
            var key2 = createComplexCtorC(len);

            key2.B = 2;
            a.Add(key2, createComplexCtorC(len));
            var key3 = new TestCtorA(new string('A', len), 3);

            a.Add(key3, new TestCtorB(new string('A', len), 3));



            await Test(a,
                       CheckIEnumerableOfIIDictionary(a,
                                                      (a, b) => checkCtorCProc(a)(b),
                                                      (a, b) => checkCtorCProc(a)(b)), new BinarySerializerOptions()
            {
                DefaultBufferSize = 1
            });
        }
Esempio n. 4
0
        public async Task Test_Larg_Ctor()
        {
            TestCtorA a = new TestCtorA("A", 0);

            await Test(a, checkTestCtorA(a), largCtorOptions);

            a.C = "C";
            await Test(a, checkTestCtorA(a), largCtorOptions);
        }
        public async Task Test_Simple_Ctor()
        {
            TestCtorA a = new TestCtorA("A", 0);

            await Test(a, checkTestCtorA(a));

            a.C = "C";
            await Test(a, checkTestCtorA(a));
        }
 private Action <TestCtorA> checkTestCtorA(TestCtorA a)
 {
     return((b) =>
     {
         Assert.Equal(a.A, b.A);
         Assert.Equal(a.B, b.B);
         Assert.Equal(a.C, b.C);
     });
 }
        public async Task Test_Simple_Ctor_Buffer(int len)
        {
            BinarySerializerOptions options = new BinarySerializerOptions()
            {
                DefaultBufferSize = 1
            };
            TestCtorA a = new TestCtorA(new string('A', len), 0);

            await Test(a, checkTestCtorA(a), options);

            a.C = new string('C', len);
            await Test(a, checkTestCtorA(a), options);
        }
Esempio n. 8
0
        internal Action <TestCtorA> checkCtorCProc(TestCtorA a)
        {
            Action <TestCtorA> check = b =>
            {
                Assert.Equal(a.GetType(), b.GetType());
                Assert.Equal(a.A, b.A);
                Assert.Equal(a.B, b.B);

                if (a is TestCtorB cb)
                {
                    TestCtorB cb2 = b as TestCtorB;
                    Assert.Equal(cb.C, cb2.C);
                    Assert.Equal(cb.EnumA, cb2.EnumA);
                    if (cb.TestA == null)
                    {
                        Assert.Null(cb2.TestA);
                    }
                    else
                    {
                        checkTestAProc(cb.TestA)(cb2.TestA);
                    }
                }
                if (a is TestCtorC cc)
                {
                    TestCtorB p1 = cc.Parent;
                    TestCtorB p2 = (b as TestCtorC).Parent;
                    if (p1 == null)
                    {
                        Assert.Null(p2);
                    }
                    else
                    {
                        checkCtorCProc(p1).Invoke(p2);
                    }


                    TestCtorA t1 = cc.Temp;
                    TestCtorA t2 = (b as TestCtorC).Temp;
                    if (t1 == null)
                    {
                        Assert.Null(t2);
                    }
                    else
                    {
                        checkCtorCProc(t1).Invoke(t2);
                    }
                }
            };

            return(check);
        }
Esempio n. 9
0
        public async Task Test_Larg_Ctor_Buffer(int len)
        {
            BinarySerializerOptions options = new BinarySerializerOptions()
            {
                DefaultBufferSize = 1,
                IgnoreCtorParameterCountThreshold = true
            };
            TestCtorA a = new TestCtorA(new string('A', len), 0);

            await Test(a, checkTestCtorA(a), options);

            a.C = new string('C', len);
            await Test(a, checkTestCtorA(a), options);
        }
Esempio n. 10
0
        public async Task Test_Array_Complex_Object()
        {
            TestCtorA[] a1 = new TestCtorA[]
            {
                createComplexCtorC(1),
                createComplexCtorC(2),
                null,
                createComplexCtorC(3),
                null
            };


            await Test(a1, CheckIEnumerable(a1, (a, b) => checkCtorCProc(a)(b)));
        }
Esempio n. 11
0
        public async Task Test_Larg_Object_Ctor_Buffer(int len)
        {
            BinarySerializerOptions options = new BinarySerializerOptions()
            {
                DefaultBufferSize = 1,
                IgnoreCtorParameterCountThreshold = true
            };

            TestCtorB b = new TestCtorB(new string('B', len), 1);

            b.C = new string('C', len);
            TestCtorA a = new TestCtorA(new string('A', len), 1);

            TestCtorC c = new TestCtorC(b, a);

            await Test <TestCtorC>(c, checkCtorCProc(c), options);



            b.TestA = new ObjTestB()
            {
                A = 1,
                D = new ObjTestB()
                {
                    A = 1,
                    B = new string('B', len),
                    D = new ObjTestA()
                    {
                        A = 2
                    }
                },
                E = 1,
                C = new ObjTestB()
                {
                    A = 1,
                    B = new string('B', len)
                }
            };

            options = new BinarySerializerOptions()
            {
                DefaultBufferSize = 32
            };
            await Test <TestCtorC>(c, checkCtorCProc(c), options);
        }
        public async Task Test_Ctor_With_Parameter_Simple_Ref()
        {
            TestCtorA item = new TestCtorA("A", 1);

            TestRef <TestCtorA> a = new TestRef <TestCtorA>();

            a.A = item;
            a.B = item;

            await Test(a, b =>
            {
                Assert.True(Object.ReferenceEquals(b.A, b.B));
                checkCtorCProc(item)(b.A);
            }, new BinarySerializerOptions()
            {
                DefaultBufferSize = 1
            });
        }
Esempio n. 13
0
        public async Task Test_Array_Ctor_Object()
        {
            TestCtorA[] a1 = new TestCtorA[]
            {
                createComplexCtorC(1),
                createComplexCtorC(2),
                null,
                createComplexCtorC(3),
                null
            };

            TestArrayCtorObj obj = new TestArrayCtorObj(a1);


            await Test(obj, b =>
            {
                CheckIEnumerable(obj.A, (a, b) => checkCtorCProc(a)(b));
            });
        }
 public TestCtorC(TestCtorB parent, TestCtorA temp) : base(parent.A, parent.B)
 {
     Temp   = temp;
     Parent = parent;
 }
Esempio n. 15
0
 public TrySkipA(TestCtorA testA)
 {
     TestA = testA;
 }
Esempio n. 16
0
 public void Add(TestCtorA item)
 {
     _list.Add(item);
 }