Example #1
0
 public void TestAddDataSerializableFactoryWithBadId()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         var config = new SerializationOptions();
         config.AddDataSerializableFactory(-1, new MyDataSerializableFactory());
         var service = new SerializationServiceBuilder(new NullLoggerFactory()).SetConfig(config).Build();
     });
 }
Example #2
0
 public void TestAddDataSerializableFactoryWitDuplicateId()
 {
     Assert.Throws <InvalidOperationException>(() =>
     {
         var config = new SerializationOptions();
         config.AddDataSerializableFactory(1, new MyDataSerializableFactory());
         var service = new SerializationServiceBuilder(new NullLoggerFactory()).SetConfig(config).
                       AddDataSerializableFactory(1, new MyDataSerializableFactory()).Build();
     });
 }
Example #3
0
        public void TestAddDataSerializableFactory()
        {
            var service1 = new SerializationServiceBuilder(new NullLoggerFactory()).Build();
            var data     = service1.ToData(new DataSerializableBasicType());

            var config = new SerializationOptions();

            config.AddDataSerializableFactory(1, new MyDataSerializableFactory());
            var service = new SerializationServiceBuilder(new NullLoggerFactory()).SetConfig(config).Build();

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

            Assert.IsInstanceOf <DataSerializableBasicType>(obj);
        }