public void Json_ModelsWithParsableObjectsAndSerializerModifierNotUsingParse() { var originalObject = new TestModelWithParsableMembersWithoutAttributes(); originalObject.Vector = new Vector(1, 2, 3); var serializationManager = new SerializationManager(); serializationManager.AddSerializerModifier <TestModelWithParsableMembersWithoutAttributes, TestModelWithParsableMembersNotUsingParseSerializerModifier>(); TestJsonSerializationWithExpectedFormat(originalObject, serializationManager); }
public void AddsSerializerModifier() { var serializationManager = new SerializationManager(); var modifiers = serializationManager.GetSerializerModifiers <DynamicSerializerModifierModel>(); Assert.AreEqual(0, modifiers.Length); serializationManager.AddSerializerModifier <DynamicSerializerModifierModel, DynamicSerializerModifier>(); modifiers = serializationManager.GetSerializerModifiers(typeof(DynamicSerializerModifierModel)); Assert.AreEqual(1, modifiers.Length); Assert.AreEqual(typeof(DynamicSerializerModifier), modifiers[0].GetType()); }
public void SerializesModelsWithParsableObjectsAndSerializerModifierNotUsingParse() { var originalObject = new TestModelWithParsableMembersWithoutAttributes(); originalObject.Vector = new Vector(1, 2, 3); var serializationManager = new SerializationManager(); serializationManager.AddSerializerModifier <TestModelWithParsableMembersWithoutAttributes, TestModelWithParsableMembersNotUsingParseSerializerModifier>(); TestSerializationOnAllSerializers((serializer, description) => { var clonedObject = SerializationTestHelper.SerializeAndDeserialize(originalObject, serializer); Assert.IsFalse(clonedObject.Vector.UsedParse); Assert.AreEqual(originalObject.Vector.X, clonedObject.Vector.X, description); Assert.AreEqual(originalObject.Vector.Y, clonedObject.Vector.Y, description); Assert.AreEqual(originalObject.Vector.Z, clonedObject.Vector.Z, description); }, serializationManager: serializationManager); }
public void ThrowsArgumentNullExceptionForNullType() { var serializationManager = new SerializationManager(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => serializationManager.AddSerializerModifier(null, typeof(DynamicSerializerModifier))); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => serializationManager.AddSerializerModifier(typeof(DynamicSerializerModifierModel), null)); }