public void Prefer_interfaces_should_work_on_top_level_object_using_extension_method()
        {
            using (JsConfig.With(preferInterfaces:true))
            {
                var json = new Concrete("boo", 1).ToJson();

                Assert.That(json, Is.StringContaining("\"NServiceKit.Text.Tests.JsonTests.IContract, NServiceKit.Text.Tests\""));
            }
        }
        public void Should_not_use_interface_type_if_concrete_specified()
        {
            using (JsConfig.With(preferInterfaces: false))
            {
                IContract myConcrete = new Concrete("boo", 1);
                var json = JsonSerializer.SerializeToString(myConcrete, typeof(IContract));

                Console.WriteLine(json);
                Assert.That(json, Is.StringContaining("\"NServiceKit.Text.Tests.JsonTests.Concrete, NServiceKit.Text.Tests\""));
            }
        }
        public void Should_be_able_to_serialise_based_on_an_interface()
        {
            using (JsConfig.With(preferInterfaces: true))
            {
                IContract myConcrete = new Concrete("boo", 1);
                var json = JsonSerializer.SerializeToString(myConcrete, typeof(IContract));

                Console.WriteLine(json);
                Assert.That(json, Is.StringContaining("\"NServiceKit.Text.Tests.JsonTests.IContract, NServiceKit.Text.Tests\""));
            }
        }
        public void Should_be_able_to_deserialise_based_on_an_interface_with_no_concrete()
        {
            using (JsConfig.With(preferInterfaces: true))
            {
                var json = new Concrete("boo", 42).ToJson();

                // break the typing so we have to use the dynamic implementation
                json = json.Replace("NServiceKit.Text.Tests.JsonTests.IContract", "NServiceKit.Text.Tests.JsonTests.IIdenticalContract");

                var result = JsonSerializer.DeserializeFromString<IIdenticalContract>(json);

                Assert.That(result.StringValue, Is.EqualTo("boo"));
                Assert.That(result.ChildProp.IntValue, Is.EqualTo(42));
            }
        }