From 01f1c5e2616cf5da542c19e428c59486c285ddfb Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sat, 18 Oct 2014 08:36:05 +1300 Subject: [PATCH] -Fixed test error caused by StringDictionary now implementing IDictionary --- .../Serialization/JsonSerializerTest.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs index 67d11e43..a55c975a 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs @@ -4627,7 +4627,20 @@ To fix this error either change the environment to be fully trusted, change the string json = JsonConvert.SerializeObject(s1, Formatting.Indented); - ExceptionAssert.Throws(() => { JsonConvert.DeserializeObject(json); }, "Cannot create and populate list type " + classRef + ". Path 'StringDictionaryProperty', line 2, position 32."); + // .NET 4.5.3 added IDictionary to StringDictionary + if (s1.StringDictionaryProperty is IDictionary) + { + StringDictionaryTestClass d = JsonConvert.DeserializeObject(json); + + Assert.AreEqual(3, d.StringDictionaryProperty.Count); + Assert.AreEqual("One", d.StringDictionaryProperty["1"]); + Assert.AreEqual("II", d.StringDictionaryProperty["2"]); + Assert.AreEqual("3", d.StringDictionaryProperty["3"]); + } + else + { + ExceptionAssert.Throws(() => { JsonConvert.DeserializeObject(json); }, "Cannot create and populate list type " + classRef + ". Path 'StringDictionaryProperty', line 2, position 32."); + } } #endif