From 4b9ce67ab7c5bd448cea60b7b1d6419df0940ab6 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Fri, 12 Sep 2014 20:55:20 +1200 Subject: [PATCH] -Fixed WinRT build --- Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs | 2 ++ .../Newtonsoft.Json.Tests.WinRT.csproj | 3 +++ .../Serialization/JsonSerializerTest.cs | 2 ++ Src/Newtonsoft.Json.Tests/TestFixtureBase.cs | 14 ++++++++++---- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs index bdda8102..cd7bfcee 100644 --- a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs +++ b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs @@ -55,6 +55,7 @@ namespace Newtonsoft.Json.Tests.Bson { private const char Euro = '\u20ac'; +#if !NETFX_CORE [Test] public void DeserializeLargeBsonObject() { @@ -67,6 +68,7 @@ namespace Newtonsoft.Json.Tests.Bson Assert.AreEqual("1", (string)o["$id"]); } +#endif [Test] public void CloseInput() diff --git a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WinRT.csproj b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WinRT.csproj index 21a64178..5b53dd1b 100644 --- a/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WinRT.csproj +++ b/Src/Newtonsoft.Json.Tests/Newtonsoft.Json.Tests.WinRT.csproj @@ -371,6 +371,9 @@ + + PreserveNewest + diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs index 9ca9331a..4db0d7a2 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs @@ -7473,7 +7473,9 @@ To fix this error either change the environment to be fully trusted, change the } #endif +#if !NETFX_CORE [Serializable] +#endif [DataContract] public struct Pair { diff --git a/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs b/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs index b2971e58..2fa8666c 100644 --- a/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs +++ b/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs @@ -164,18 +164,23 @@ namespace Newtonsoft.Json.Tests public static void Contains(IList collection, object value) { + Contains(collection, value, null); + } + + public static void Contains(IList collection, object value, string message) + { #if !NETFX_CORE - Assert.Contains(value, collection); + Assert.Contains(value, collection, message); #else if (!collection.Cast().Any(i => i.Equals(value))) - throw new Exception("Value not found in collection."); + throw new Exception(message ?? "Value not found in collection."); #endif } } public static class StringAssert { - private readonly static Regex Regex = new Regex(@"\r\n|\n\r|\n|\r", RegexOptions.CultureInvariant | RegexOptions.Compiled); + private readonly static Regex Regex = new Regex(@"\r\n|\n\r|\n|\r", RegexOptions.CultureInvariant); public static void AreEqual(string expected, string actual) { @@ -222,7 +227,8 @@ namespace Newtonsoft.Json.Tests } catch (TException ex) { - Assert.Contains (ex.Message, possibleMessages, "Unexpected exception message." + Environment.NewLine + "Expected One of: " + string.Join (Environment.NewLine, possibleMessages) + Environment.NewLine + "Got: " + ex.Message + Environment.NewLine + Environment.NewLine + ex); + if (possibleMessages != null && possibleMessages.Length > 0) + CustomAssert.Contains(possibleMessages, ex.Message, "Unexpected exception message." + Environment.NewLine + "Expected one of: " + string.Join(Environment.NewLine, possibleMessages) + Environment.NewLine + "Got: " + ex.Message + Environment.NewLine + Environment.NewLine + ex); } catch (Exception ex) {