Fix missing error when deserializing JToken with a contract type mismatch (#2494)

This commit is contained in:
James Newton-King
2021-03-11 21:42:55 +13:00
committed by GitHub
parent b6dc05be5a
commit 583eb12015
3 changed files with 66 additions and 6 deletions
@@ -3515,13 +3515,9 @@ Path '', line 1, position 1.");
{
string json = @"[]";
ExceptionAssert.Throws<InvalidCastException>(
ExceptionAssert.Throws<JsonSerializationException>(
() => { JsonConvert.DeserializeObject<JObject>(json); },
new[]
{
"Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'Newtonsoft.Json.Linq.JObject'.",
"Cannot cast from source type to destination type." // mono
});
"Deserialized JSON type 'Newtonsoft.Json.Linq.JArray' is not compatible with expected type 'Newtonsoft.Json.Linq.JObject'. Path '', line 1, position 2.");
}
[Test]