public void TestClassDefinitionConfig()
        {
            var serializationConfig = new SerializationConfig();

            serializationConfig.AddPortableFactory(TestSerializationConstants.PORTABLE_FACTORY_ID,
                                                   new TestPortableFactory());
            serializationConfig.SetPortableVersion(1);
            serializationConfig
            .AddClassDefinition(
                new ClassDefinitionBuilder(TestSerializationConstants.PORTABLE_FACTORY_ID,
                                           TestSerializationConstants.RAW_DATA_PORTABLE)
                .AddLongField("l")
                .AddCharArrayField("c")
                .AddPortableField("p", CreateNamedPortableClassDefinition())
                .Build())
            .AddClassDefinition(
                new ClassDefinitionBuilder(TestSerializationConstants.PORTABLE_FACTORY_ID,
                                           TestSerializationConstants.NAMED_PORTABLE)
                .AddUTFField("name").AddIntField("myint").Build());

            var serializationService = new SerializationServiceBuilder()
                                       .SetConfig(serializationConfig)
                                       .AddDataSerializableFactory(TestSerializationConstants.DATA_SERIALIZABLE_FACTORY_ID,
                                                                   GetDataSerializableFactory())
                                       .Build();
            var p = new RawDataPortable(DateTime.Now.ToFileTime(), "test chars".ToCharArray(),
                                        new NamedPortable("named portable", 34567),
                                        9876, "Testing raw portable", new ByteArrayDataSerializable(Encoding.UTF8.GetBytes("test bytes")));

            var data = serializationService.ToData(p);

            Assert.AreEqual(p, serializationService.ToObject <RawDataPortable>(data));
        }
        public void TestRawDataWithoutRegistering()
        {
            var serializationService = CreateSerializationService(1, ByteOrder.BigEndian);
            var p = new RawDataPortable(DateTime.Now.ToFileTime(), "test chars".ToCharArray(),
                                        new NamedPortable("named portable", 34567),
                                        9876, "Testing raw portable", new ByteArrayDataSerializable(Encoding.UTF8.GetBytes("test bytes")));

            var data = serializationService.ToData(p);

            Assert.AreEqual(p, serializationService.ToObject <RawDataPortable>(data));
        }
Ejemplo n.º 3
0
        public void TestRawData()
        {
            var serializationService = CreateSerializationService(1, ByteOrder.BigEndian);
            var p = new RawDataPortable(DateTime.Now.ToFileTime(), "test chars".ToCharArray(),
                                        new NamedPortable("named portable", 34567),
                                        9876, "Testing raw portable", new ByteArrayDataSerializable(Encoding.UTF8.GetBytes("test bytes")));
            var builder = new ClassDefinitionBuilder(p.GetFactoryId(), p.GetClassId());

            builder.AddLongField("l").AddCharArrayField("c").AddPortableField("p", CreateNamedPortableClassDefinition());
            serializationService.GetPortableContext().RegisterClassDefinition(builder.Build());

            var data = serializationService.ToData(p);

            Assert.AreEqual(p, serializationService.ToObject <RawDataPortable>(data));
        }
        public void TestRawDataWithoutRegistering()
        {
            var serializationService = CreateSerializationService(1, ByteOrder.BigEndian);
            var p = new RawDataPortable(DateTime.Now.ToFileTime(), "test chars".ToCharArray(),
                new NamedPortable("named portable", 34567),
                9876, "Testing raw portable", new ByteArrayDataSerializable(Encoding.UTF8.GetBytes("test bytes")));

            var data = serializationService.ToData(p);
            Assert.AreEqual(p, serializationService.ToObject<RawDataPortable>(data));
        }
        public void TestRawData()
        {
            var serializationService = CreateSerializationService(1, ByteOrder.BigEndian);
            var p = new RawDataPortable(DateTime.Now.ToFileTime(), "test chars".ToCharArray(),
                new NamedPortable("named portable", 34567),
                9876, "Testing raw portable", new ByteArrayDataSerializable(Encoding.UTF8.GetBytes("test bytes")));
            var builder = new ClassDefinitionBuilder(p.GetFactoryId(), p.GetClassId());
            builder.AddLongField("l").AddCharArrayField("c").AddPortableField("p", CreateNamedPortableClassDefinition());
            serializationService.GetPortableContext().RegisterClassDefinition(builder.Build());

            var data = serializationService.ToData(p);
            Assert.AreEqual(p, serializationService.ToObject<RawDataPortable>(data));
        }
        public void TestClassDefinitionConfig()
        {
            var serializationConfig = new SerializationConfig();
            serializationConfig.AddPortableFactory(TestSerializationConstants.PORTABLE_FACTORY_ID,
                new TestPortableFactory());
            serializationConfig.SetPortableVersion(1);
            serializationConfig
                .AddClassDefinition(
                    new ClassDefinitionBuilder(TestSerializationConstants.PORTABLE_FACTORY_ID,
                        TestSerializationConstants.RAW_DATA_PORTABLE)
                        .AddLongField("l")
                        .AddCharArrayField("c")
                        .AddPortableField("p", CreateNamedPortableClassDefinition())
                        .Build())
                .AddClassDefinition(
                    new ClassDefinitionBuilder(TestSerializationConstants.PORTABLE_FACTORY_ID,
                        TestSerializationConstants.NAMED_PORTABLE)
                        .AddUTFField("name").AddIntField("myint").Build());

            var serializationService = new SerializationServiceBuilder()
                .SetConfig(serializationConfig)
                .AddDataSerializableFactory(TestSerializationConstants.DATA_SERIALIZABLE_FACTORY_ID,
                    GetDataSerializableFactory())
                .Build();
            var p = new RawDataPortable(DateTime.Now.ToFileTime(), "test chars".ToCharArray(),
                new NamedPortable("named portable", 34567),
                9876, "Testing raw portable", new ByteArrayDataSerializable(Encoding.UTF8.GetBytes("test bytes")));

            var data = serializationService.ToData(p);
            Assert.AreEqual(p, serializationService.ToObject<RawDataPortable>(data));
        }
 protected bool Equals(RawDataPortable other)
 {
     return c.SequenceEqual(other.c) && k == other.k && l == other.l && Equals(p, other.p) && string.Equals(s, other.s) &&
            Equals(sds, other.sds);
 }
Ejemplo n.º 8
0
 protected bool Equals(RawDataPortable other)
 {
     return(c.SequenceEqual(other.c) && k == other.k && l == other.l && Equals(p, other.p) &&
            string.Equals(s, other.s) &&
            Equals(sds, other.sds));
 }