public void CorrectlySerializesObjectsImplementingICustomJsonSerializable_Simple() { var serviceLocator = ServiceLocator.Default; var serializer = serviceLocator.ResolveType <IJsonSerializer>(); var model = new CustomJsonSerializationModel { FirstName = "Geert" }; var clonedModel = SerializationTestHelper.SerializeAndDeserialize(model, serializer, null); // Note: yes, the *model* is serialized, the *clonedModel* is deserialized Assert.IsTrue(model.IsCustomSerialized); Assert.IsTrue(clonedModel.IsCustomDeserialized); Assert.AreEqual(model.FirstName, clonedModel.FirstName); }
public void CorrectlySerializesObjectsImplementingICustomJsonSerializable_Simple() { var serviceLocator = ServiceLocator.Default; var serializer = serviceLocator.ResolveType<IJsonSerializer>(); var model = new CustomJsonSerializationModel { FirstName = "Geert" }; var clonedModel = SerializationTestHelper.SerializeAndDeserialize(model, serializer, null); // Note: yes, the *model* is serialized, the *clonedModel* is deserialized Assert.IsTrue(model.IsCustomSerialized); Assert.IsTrue(clonedModel.IsCustomDeserialized); Assert.AreEqual(model.FirstName, clonedModel.FirstName); }
public void CorrectlySerializesObjectsWithFormattedIndents() { var serviceLocator = ServiceLocator.Default; var serializer = serviceLocator.ResolveType <IJsonSerializer>(); var model = new CustomJsonSerializationModel { FirstName = "Geert" }; var configuration = new JsonSerializationConfiguration { Formatting = Newtonsoft.Json.Formatting.Indented }; var clonedModel = SerializationTestHelper.SerializeAndDeserialize(model, serializer, configuration); // Note: yes, the *model* is serialized, the *clonedModel* is deserialized Assert.IsTrue(model.IsCustomSerialized); Assert.IsTrue(clonedModel.IsCustomDeserialized); Assert.AreEqual(model.FirstName, clonedModel.FirstName); }