Add JsonContract.InternalConverter (#2028)

This commit is contained in:
James Newton-King
2019-03-30 19:31:01 +13:00
committed by GitHub
parent 064cfafa91
commit af963131ba
3 changed files with 33 additions and 6 deletions
@@ -47,6 +47,8 @@ using System.Reflection;
using Newtonsoft.Json.Utilities;
using System.Globalization;
using Newtonsoft.Json.Linq;
using System.Text.RegularExpressions;
using Newtonsoft.Json.Converters;
namespace Newtonsoft.Json.Tests.Serialization
{
@@ -812,5 +814,25 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(Required.AllowNull, allowNull.Required);
Assert.AreEqual(true, allowNull.IsRequiredSpecified);
}
[Test]
public void InternalConverter_Object_NotSet()
{
DefaultContractResolver resolver = new DefaultContractResolver();
JsonObjectContract contract = (JsonObjectContract)resolver.ResolveContract(typeof(object));
Assert.IsNull(contract.InternalConverter);
}
[Test]
public void InternalConverter_Regex_Set()
{
DefaultContractResolver resolver = new DefaultContractResolver();
JsonContract contract = resolver.ResolveContract(typeof(Regex));
Assert.IsInstanceOf(typeof(RegexConverter), contract.InternalConverter);
}
}
}