public void SerializeAndDeserialize_WithMultipleUserDefinedAdapters_OnlyTheFirstAdapterIsInvoked()
        {
            var jsonSerializationParameters = new JsonSerializationParameters
            {
                UserDefinedAdapters = new List <IJsonAdapter>
                {
                    // The order is important here.
                    new TestInverter(),
                    new TestAdapter(),
                    new TestDecorator()
                }
            };

            var src = new ClassWithAdaptedTypes
            {
                Value = new ClassWithAdapters {
                    A = 42
                }
            };

            var json = JsonSerialization.ToJson(src, jsonSerializationParameters);

            Assert.That(UnFormat(json), Is.EqualTo(@"{""Value"":-42}"));

            var dst = JsonSerialization.FromJson <ClassWithAdaptedTypes>(json, jsonSerializationParameters);

            Assert.That(dst.Value.A, Is.EqualTo(src.Value.A));
        }
        public void SerializeAndDeserialize_WithUserDefinedAdapter_AdapterIsInvoked()
        {
            var jsonSerializationParameters = new JsonSerializationParameters
            {
                UserDefinedAdapters = new List <IJsonAdapter>
                {
                    new DummyAdapter(),
                    new TestAdapter()
                }
            };

            var src = new ClassWithAdaptedTypes
            {
                Value = new ClassWithAdapters {
                    A = 42
                }
            };

            var json = JsonSerialization.ToJson(src, jsonSerializationParameters);

            Assert.That(UnFormat(json), Is.EqualTo(@"{""Value"":42}"));

            var dst = JsonSerialization.FromJson <ClassWithAdaptedTypes>(json, jsonSerializationParameters);

            Assert.That(dst.Value.A, Is.EqualTo(src.Value.A));
        }
        public void SerializeAndDeserialize_WithNoUserDefinedAdapter_ValueIsSerializedNormally()
        {
            var src = new ClassWithAdaptedTypes
            {
                Value = new ClassWithAdapters {
                    A = 42
                }
            };

            var json = JsonSerialization.ToJson(src);

            Assert.That(UnFormat(json), Is.EqualTo(@"{""Value"":{""A"":42}}"));
            var dst = JsonSerialization.FromJson <ClassWithAdaptedTypes>(json);

            Assert.That(dst.Value.A, Is.EqualTo(src.Value.A));
        }