public void TestClassDefinitionConfigWithErrors()
        {
            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());

            try
            {
                new SerializationServiceBuilder().SetConfig(serializationConfig).Build();
                Assert.Fail("Should throw HazelcastSerializationException!");
            }
            catch (HazelcastSerializationException)
            {
            }

            new SerializationServiceBuilder().SetConfig(serializationConfig).SetCheckClassDefErrors(false).Build();

            // -- OR --

            serializationConfig.SetCheckClassDefErrors(false);
            new SerializationServiceBuilder().SetConfig(serializationConfig).Build();
        }
        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));
        }