Exemple #1
0
        public void TestSerializationService_CreatePortableReader()
        {
            var serializationService = new SerializationServiceBuilder(new NullLoggerFactory()).Build();

            var timestamp1  = TestUtils.RandomLong();
            var child       = new ChildPortableObject(timestamp1);
            var timestamp2  = TestUtils.RandomLong();
            var parent      = new ParentPortableObject(timestamp2, child);
            var timestamp3  = timestamp1 + timestamp2;
            var grandParent = new GrandParentPortableObject(timestamp3, parent);

            var data   = serializationService.ToData(grandParent);
            var reader = serializationService.CreatePortableReader(data);

            Assert.AreEqual(grandParent.timestamp, reader.ReadLong("timestamp"));
            Assert.AreEqual(parent.timestamp, reader.ReadLong("child.timestamp"));
            Assert.AreEqual(child.timestamp, reader.ReadLong("child.child.timestamp"));
        }
Exemple #2
0
        public virtual void TestInputOutputWithPortableReader(Endianness endianness)
        {
            var portable = KitchenSinkPortable.Generate();

            var config = new SerializationOptions();

            config.AddPortableFactory(KitchenSinkPortableFactory.FactoryId, typeof(KitchenSinkPortableFactory));

            using var ss = new SerializationServiceBuilder(new NullLoggerFactory()).SetConfig(config)
                           .SetEndianness(endianness).Build();

            var data   = ss.ToData(portable);
            var reader = ss.CreatePortableReader(data);

            var actual = new KitchenSinkPortable();

            actual.ReadPortable(reader);

            Assert.AreEqual(portable, actual);
        }
Exemple #3
0
        public virtual void TestInputOutputWithPortableReader(ByteOrder byteOrder)
        {
            var portable = KitchenSinkPortable.Generate();

            var config = new SerializationConfig();

            config.AddPortableFactoryClass(KitchenSinkPortableFactory.FactoryId, typeof(KitchenSinkPortableFactory));

            var ss = new SerializationServiceBuilder().SetConfig(config).
                     SetUseNativeByteOrder(false).SetByteOrder(byteOrder).Build();

            var data   = ss.ToData(portable);
            var reader = ss.CreatePortableReader(data);

            var actual = new KitchenSinkPortable();

            actual.ReadPortable(reader);

            Assert.AreEqual(portable, actual);

            ss.Destroy();
        }