예제 #1
0
            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);
            }
예제 #2
0
            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);
            }
예제 #3
0
            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);
            }