-Formatting

-Build
This commit is contained in:
James Newton-King
2015-12-04 23:54:38 +13:00
parent c96779dc10
commit eb0cbd6a75
334 changed files with 3952 additions and 514 deletions
@@ -70,14 +70,15 @@ namespace Newtonsoft.Json.Tests.Serialization
}
]";
var possibleMsgs = new [] {
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.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]);
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]
@@ -166,7 +167,9 @@ namespace Newtonsoft.Json.Tests.Serialization
Error = (s, e) =>
{
if (e.CurrentObject.GetType().IsArray)
{
e.ErrorContext.Handled = true;
}
}
});
@@ -294,7 +297,6 @@ namespace Newtonsoft.Json.Tests.Serialization
""2000-12-01T00:00:00Z""
]")));
// 2009-09-09T00:00:00Z
// 1977-02-20T00:00:00Z
// 2000-12-01T00:00:00Z
@@ -309,19 +311,20 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(new DateTime(2000, 12, 1, 0, 0, 0, DateTimeKind.Utc), c[2]);
Assert.AreEqual(3, errors.Count);
var possibleErrs = new [] {
var possibleErrs = new[]
{
#if !(NET20 || NET35)
"[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."
#else
// handle typo fix in later versions of .NET
// handle typo fix in later versions of .NET
"[1] - 1 - The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.",
"[1] - 1 - The string was not recognized as a valid DateTime. There is a unknown word starting at index 0."
#endif
};
Assert.IsTrue(possibleErrs.Any (m => m == errors[0]),
"Expected One of: " + string.Join (Environment.NewLine, possibleErrs) + Environment.NewLine + "But was: " + errors[0]);
Assert.IsTrue(possibleErrs.Any(m => m == errors[0]),
"Expected One of: " + string.Join(Environment.NewLine, possibleErrs) + Environment.NewLine + "But was: " + errors[0]);
Assert.AreEqual("[2] - 2 - Unexpected token parsing date. Expected String, got StartArray. Path '[2]', line 4, position 9.", errors[1]);
Assert.AreEqual("[4] - 4 - Cannot convert null value to System.DateTime. Path '[4]', line 8, position 12.", errors[2]);
@@ -395,7 +398,9 @@ namespace Newtonsoft.Json.Tests.Serialization
{
// only log an error once
if (args.CurrentObject == args.ErrorContext.OriginalObject)
{
errors.Add(args.ErrorContext.Path + " - " + args.ErrorContext.Member + " - " + args.ErrorContext.Error.Message);
}
};
serializer.Deserialize(new StringReader(json), typeof(List<List<DateTime>>));
@@ -820,7 +825,6 @@ namespace Newtonsoft.Json.Tests.Serialization
throw new NotImplementedException();
}
}
}
[Test]
@@ -850,7 +854,7 @@ namespace Newtonsoft.Json.Tests.Serialization
{
Something = s
};
var writer = new System.IO.StringWriter();
ExceptionAssert.Throws<Exception>(() => { serialiser.Serialize(writer, r); }, "An error occurred.");