private void TestObjectAPI(ArrayTable a)
        {
            var b = a.UnPack();

            AreEqual(a, b);

            var fbb = new FlatBufferBuilder(1);

            fbb.Finish(ArrayTable.Pack(fbb, b).Value);
            var c = ArrayTable.GetRootAsArrayTable(fbb.DataBuffer);

            AreEqual(a, c);

            var jsonText = b.SerializeToJson();
            var d        = ArrayTableT.DeserializeFromJson(jsonText);

            AreEqual(a, d);

            var fbBuffer = b.SerializeToBinary();

            Assert.IsTrue(ArrayTable.ArrayTableBufferHasIdentifier(new ByteBuffer(fbBuffer)));
            var e = ArrayTableT.DeserializeFromBinary(fbBuffer);

            AreEqual(a, e);
        }
示例#2
0
        private void TestObjectAPI(ArrayTable a)
        {
            var b = a.UnPack();

            AreEqual(a, b);

            var fbb = new FlatBufferBuilder(1);

            fbb.Finish(ArrayTable.Pack(fbb, b).Value);
            var c = ArrayTable.GetRootAsArrayTable(fbb.DataBuffer);

            AreEqual(a, c);

            var jsonText = b.SerializeToJson();
            var d        = ArrayTableT.DeserializeFromJson(jsonText);

            AreEqual(a, d);
        }
        private void AreEqual(ArrayTable a, ArrayTableT b)
        {
            Assert.AreEqual(a.A.Value.A, b.A.A);

            for (int i = 0; i < 15; ++i)
            {
                Assert.AreEqual(a.A.Value.B(i), b.A.B[i]);
            }

            Assert.AreEqual(a.A.Value.C, b.A.C);

            for (int i = 0; i < 2; ++i)
            {
                var ad = a.A.Value.D(i);
                var bd = b.A.D[i];

                for (int j = 0; j < 2; ++j)
                {
                    Assert.AreEqual(ad.A(j), bd.A[j]);
                }

                Assert.AreEqual(ad.B, bd.B);

                for (int j = 0; j < 2; ++j)
                {
                    Assert.AreEqual(ad.C(j), bd.C[j]);
                }

                for (int j = 0; j < 2; ++j)
                {
                    Assert.AreEqual(ad.D(j), bd.D[j]);
                }
            }

            Assert.AreEqual(a.A.Value.E, b.A.E);

            for (int i = 0; i < 2; ++i)
            {
                Assert.AreEqual(a.A.Value.F(i), b.A.F[i]);
            }
        }