public void TestAddDataSerializableFactoryClassWithNoEmptyConstructor() { Assert.Throws <ServiceFactoryException>(() => { var config = new SerializationOptions(); config.AddDataSerializableFactoryClass(1, typeof(SerializableFactory)); var service = new SerializationServiceBuilder(new NullLoggerFactory()).SetConfig(config).Build(); }); }
public void TestAddDataSerializableFactoryClassWithBadId() { Assert.Throws <ArgumentException>(() => { var config = new SerializationOptions(); config.AddDataSerializableFactoryClass(-1, typeof(MyDataSerializableFactory)); var service = new SerializationServiceBuilder(new NullLoggerFactory()).SetConfig(config).Build(); }); }
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(); }); }
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); }