Merge branch 'master' of github.com:JamesNK/Newtonsoft.Json
This commit is contained in:
@@ -141,8 +141,12 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
[Test]
|
||||
public void SerializeDefaultArray()
|
||||
{
|
||||
ExceptionAssert.Throws<NullReferenceException>("Object reference not set to an instance of an object.", () =>
|
||||
JsonConvert.SerializeObject(default(ImmutableArray<int>), Formatting.Indented));
|
||||
ExceptionAssert.Throws<NullReferenceException>(
|
||||
() => JsonConvert.SerializeObject(default(ImmutableArray<int>), Formatting.Indented),
|
||||
new [] {
|
||||
"Object reference not set to an instance of an object.",
|
||||
"Object reference not set to an instance of an object" // mono
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -2975,8 +2975,11 @@ Path '', line 1, position 1.",
|
||||
string json = @"[]";
|
||||
|
||||
ExceptionAssert.Throws<InvalidCastException>(
|
||||
@"Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'Newtonsoft.Json.Linq.JObject'.",
|
||||
() => { JsonConvert.DeserializeObject<JObject>(json); });
|
||||
() => { 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
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -6304,18 +6307,22 @@ To fix this error either change the environment to be fully trusted, change the
|
||||
public void DeserializeDoubleFromNullString()
|
||||
{
|
||||
ExceptionAssert.Throws<ArgumentNullException>(
|
||||
@"Value cannot be null.
|
||||
Parameter name: value",
|
||||
() => { JsonConvert.DeserializeObject<double>(null); });
|
||||
() => { JsonConvert.DeserializeObject<double>(null); },
|
||||
new [] {
|
||||
"Value cannot be null." + Environment.NewLine + "Parameter name: value",
|
||||
"Argument cannot be null." + Environment.NewLine + "Parameter name: value" // mono
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeserializeFromNullString()
|
||||
{
|
||||
ExceptionAssert.Throws<ArgumentNullException>(
|
||||
@"Value cannot be null.
|
||||
Parameter name: value",
|
||||
() => { JsonConvert.DeserializeObject(null); });
|
||||
() => { JsonConvert.DeserializeObject(null); },
|
||||
new [] {
|
||||
"Value cannot be null." + Environment.NewLine + "Parameter name: value",
|
||||
"Argument cannot be null." + Environment.NewLine + "Parameter name: value" // mono
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -66,10 +66,14 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}
|
||||
]";
|
||||
|
||||
var possibleMsgs = new [] {
|
||||
"[1] - Error message for member 1 = An item with the same key has already been added.",
|
||||
"[1] - Error message for member 1 = An element with the same key already exists in the dictionary." // mono
|
||||
};
|
||||
VersionKeyedCollection c = JsonConvert.DeserializeObject<VersionKeyedCollection>(json);
|
||||
Assert.AreEqual(1, c.Count);
|
||||
Assert.AreEqual(1, c.Messages.Count);
|
||||
Assert.AreEqual("[1] - Error message for member 1 = An item with the same key has already been added.", c.Messages[0]);
|
||||
Assert.IsTrue (possibleMsgs.Any (m => m == c.Messages[0]), "Expected One of: " + Environment.NewLine + string.Join (Environment.NewLine, possibleMsgs) + Environment.NewLine + "Was: " + Environment.NewLine + c.Messages[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -302,7 +306,13 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
|
||||
Assert.AreEqual(3, errors.Count);
|
||||
#if !(NET20 || NET35)
|
||||
Assert.AreEqual("[1] - 1 - The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.", errors[0]);
|
||||
var possibleErrs = new [] {
|
||||
"[1] - 1 - The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.",
|
||||
"[1] - 1 - String was not recognized as a valid DateTime."
|
||||
};
|
||||
|
||||
Assert.IsTrue(possibleErrs.Any (m => m == errors[0]),
|
||||
"Expected One of: " + string.Join (Environment.NewLine, possibleErrs) + Environment.NewLine + "But was: " + errors[0]);
|
||||
#else
|
||||
Assert.AreEqual("[1] - 1 - The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.", errors[0]);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user