예제 #1
0
 public void TestAddDataSerializableFactoryClassWithNoEmptyConstructor()
 {
     Assert.Throws <ServiceFactoryException>(() =>
     {
         var config = new SerializationOptions();
         config.AddDataSerializableFactoryClass(1, typeof(SerializableFactory));
         var service = new SerializationServiceBuilder(new NullLoggerFactory()).SetConfig(config).Build();
     });
 }
예제 #2
0
 public void TestAddDataSerializableFactoryClassWithBadId()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         var config = new SerializationOptions();
         config.AddDataSerializableFactoryClass(-1, typeof(MyDataSerializableFactory));
         var service = new SerializationServiceBuilder(new NullLoggerFactory()).SetConfig(config).Build();
     });
 }
예제 #3
0
 public void TestAddDataSerializableFactoryClassWithDuplicateId()
 {
     Assert.Throws <InvalidOperationException>(() =>
     {
         var config = new SerializationOptions();
         config.AddDataSerializableFactory(1, new MyDataSerializableFactory());
         config.AddDataSerializableFactoryClass(1, typeof(MyDataSerializableFactory));
         var service = new SerializationServiceBuilder(new NullLoggerFactory()).SetConfig(config).Build();
     });
 }
예제 #4
0
        public void TestAddDataSerializableFactoryClass()
        {
            var service1 = new SerializationServiceBuilder(new NullLoggerFactory()).Build();
            var data     = service1.ToData(new DataSerializableBasicType());

            var config = new SerializationOptions();

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

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

            Assert.IsInstanceOf <DataSerializableBasicType>(obj);
        }