From 59a3ff8b2aa25de8460c26259e44d229827de464 Mon Sep 17 00:00:00 2001 From: Redth Date: Tue, 9 Sep 2014 09:40:07 -0400 Subject: [PATCH] Added check for multiple exception messages to match for mono Some tests check explicitly for a given exception message which differs on Mono, so added possible options to check for so both platforms will pass --- .../SerializationErrorHandlingTests.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs index db328fd4..70306dd5 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs @@ -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(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