-Add support for sharing a static cache for contract resolvers inheriting from DefaultControlResolver
-Correct error message when casting non-JValue to a privative type
This commit is contained in:
@@ -1449,5 +1449,35 @@ Parameter name: arrayIndex")]
|
||||
""title"": null
|
||||
}", output);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Can not convert Object to String.")]
|
||||
public void InvalidValueCastExceptionMessage()
|
||||
{
|
||||
string json = @"{
|
||||
""responseData"": {},
|
||||
""responseDetails"": null,
|
||||
""responseStatus"": 200
|
||||
}";
|
||||
|
||||
JObject o = JObject.Parse(json);
|
||||
|
||||
string name = (string)o["responseData"];
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Can not convert Object to String.")]
|
||||
public void InvalidPropertyValueCastExceptionMessage()
|
||||
{
|
||||
string json = @"{
|
||||
""responseData"": {},
|
||||
""responseDetails"": null,
|
||||
""responseStatus"": 200
|
||||
}";
|
||||
|
||||
JObject o = JObject.Parse(json);
|
||||
|
||||
string name = (string)o.Property("responseData");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,5 +178,13 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
JToken t = new JValue(5L);
|
||||
t[0] = new JValue(3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Can not convert Null to Int32.")]
|
||||
public void CastNullValueToNonNullable()
|
||||
{
|
||||
JValue v = new JValue((object)null);
|
||||
int i = (int) v;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user