Beispiel #1
0
        public void TestAddPortableFactoryClassWithBadId()
        {
            var config = new SerializationConfig();

            config.AddPortableFactoryClass(-1, typeof(KitchenSinkPortableFactory));

            var service = new SerializationServiceBuilder().SetConfig(config).Build();
        }
Beispiel #2
0
        public void TestAddPortableFactoryClassWithNoEmptyConstructor()
        {
            var config = new SerializationConfig();

            config.AddPortableFactoryClass(1, typeof(PortableFactory));

            var service = new SerializationServiceBuilder().SetConfig(config).Build();
        }
Beispiel #3
0
        public void TestAddPortableFactoryClassWhichDoesNotImplementPortableFactory()
        {
            var config = new SerializationConfig();

            config.AddPortableFactoryClass(1, typeof(SerializableFactory));

            var service = new SerializationServiceBuilder().SetConfig(config).Build();
        }
Beispiel #4
0
        public void TestAddPortableFactoryClassWithNoEmptyConstructor()
        {
            Assert.Throws <MissingMethodException>(() =>
            {
                var config = new SerializationConfig();
                config.AddPortableFactoryClass(1, typeof(PortableFactory));

                var service = new SerializationServiceBuilder().SetConfig(config).Build();
            });
        }
Beispiel #5
0
        public void TestAddPortableFactoryClassWithBadId()
        {
            Assert.Throws <ArgumentException>(() =>
            {
                var config = new SerializationConfig();
                config.AddPortableFactoryClass(-1, typeof(KitchenSinkPortableFactory));

                var service = new SerializationServiceBuilder().SetConfig(config).Build();
            });
        }
Beispiel #6
0
        public void TestAddPortableFactoryClassWhichDoesNotImplementPortableFactory()
        {
            Assert.Throws <HazelcastSerializationException>(() =>
            {
                var config = new SerializationConfig();
                config.AddPortableFactoryClass(1, typeof(SerializableFactory));

                var service = new SerializationServiceBuilder().SetConfig(config).Build();
            });
        }
Beispiel #7
0
        public void TestAddPortableFactoryClass()
        {
            var service1 = new SerializationServiceBuilder().Build();
            var data     = service1.ToData(new KitchenSinkPortable());

            var config = new SerializationConfig();

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

            var service = new SerializationServiceBuilder().SetConfig(config).Build();

            var obj = service.ToObject <object>(data);

            Assert.IsInstanceOf <KitchenSinkPortable>(obj);
        }
Beispiel #8
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();
        }
Beispiel #9
0
        public virtual void TestDataInputOutputWithPortable(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();

            IObjectDataOutput output = ss.CreateObjectDataOutput(1024);

            output.WriteObject(portable);
            var data = output.ToByteArray();

            IObjectDataInput input = ss.CreateObjectDataInput(data);
            var readObject         = input.ReadObject <IPortable>();

            Assert.AreEqual(portable, readObject);

            ss.Destroy();
        }