Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/Newtonsoft.Json.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamesNK <james@newtonking.com>2011-10-01 08:41:09 +0400
committerJamesNK <james@newtonking.com>2011-10-01 08:41:09 +0400
commit3baf856f921192904b2d931bd10f515bd91bec7e (patch)
tree8b6c8159ab6a7ac23a5487c0f2e645374f72ab42 /Src/Newtonsoft.Json.Tests
parent7d3ce867da7620f8c6c3961e1833c5c37df4730b (diff)
-Documentation
-Fixed JObject loading JSON with comments -Fixed error when using a Specified property with no setter -Fixed transient constructor error on Windows Phone 7 -Fixed deserializing null values into nullable generic dictionaries
Diffstat (limited to 'Src/Newtonsoft.Json.Tests')
-rw-r--r--Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs6
-rw-r--r--Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs2
-rw-r--r--Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs41
3 files changed, 47 insertions, 2 deletions
diff --git a/Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs
index 731e344..587ffdb 100644
--- a/Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs
+++ b/Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs
@@ -1591,6 +1591,12 @@ Parameter name: arrayIndex")]
Assert.AreEqual(false, prop4.ShouldSerializeValue(o));
}
#endif
+ [Test]
+ public void ParseEmptyObjectWithComment()
+ {
+ JObject o = JObject.Parse("{ /* A Comment */ }");
+ Assert.AreEqual(0, o.Count);
+ }
[Test]
public void FromObjectTimeSpan()
diff --git a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs
index eb1028f..4c00c76 100644
--- a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs
+++ b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs
@@ -41,5 +41,5 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.0.2.0")]
#if !PocketPC
-[assembly: AssemblyFileVersion("4.0.2.14003")]
+[assembly: AssemblyFileVersion("4.0.2.14201")]
#endif
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
index c446773..0110be7 100644
--- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
+++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
@@ -3426,6 +3426,7 @@ keyword such as type of business.""
public int Age { get; set; }
public int Weight { get; set; }
public int Height { get; set; }
+ public int FavoriteNumber { get; set; }
// dummy. should never be used because it isn't of type bool
[JsonIgnore]
@@ -3444,6 +3445,14 @@ keyword such as type of business.""
[JsonIgnore]
[System.Xml.Serialization.XmlIgnoreAttribute]
public bool HeightSpecified;
+
+ [JsonIgnore]
+
+ public bool FavoriteNumberSpecified
+ {
+ // get only example
+ get { return FavoriteNumber != 0; }
+ }
}
[Test]
@@ -3465,18 +3474,21 @@ keyword such as type of business.""
Assert.IsFalse(deserialized.NameSpecified);
Assert.IsFalse(deserialized.WeightSpecified);
Assert.IsFalse(deserialized.HeightSpecified);
+ Assert.IsFalse(deserialized.FavoriteNumberSpecified);
Assert.AreEqual(27, deserialized.Age);
c.NameSpecified = true;
c.WeightSpecified = true;
c.HeightSpecified = true;
+ c.FavoriteNumber = 23;
json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
""Name"": ""James"",
""Age"": 27,
""Weight"": 0,
- ""Height"": 0
+ ""Height"": 0,
+ ""FavoriteNumber"": 23
}", json);
deserialized = JsonConvert.DeserializeObject<SpecifiedTestClass>(json);
@@ -3484,7 +3496,9 @@ keyword such as type of business.""
Assert.IsTrue(deserialized.NameSpecified);
Assert.IsTrue(deserialized.WeightSpecified);
Assert.IsTrue(deserialized.HeightSpecified);
+ Assert.IsTrue(deserialized.FavoriteNumberSpecified);
Assert.AreEqual(27, deserialized.Age);
+ Assert.AreEqual(23, deserialized.FavoriteNumber);
}
// [Test]
@@ -4844,6 +4858,31 @@ keyword such as type of business.""
Assert.AreEqual(c1.NullableTimeSpan, c2.NullableTimeSpan);
Assert.AreEqual(c1.Uri, c2.Uri);
}
+
+ [Test]
+ public void NullableValueGenericDictionary()
+ {
+ IDictionary<string, int?> v1 = new Dictionary<string, int?>
+ {
+ { "First", 1 },
+ { "Second", null },
+ { "Third", 3 }
+ };
+
+ string json = JsonConvert.SerializeObject(v1, Formatting.Indented);
+
+ Assert.AreEqual(@"{
+ ""First"": 1,
+ ""Second"": null,
+ ""Third"": 3
+}", json);
+
+ IDictionary<string, int?> v2 = JsonConvert.DeserializeObject<IDictionary<string, int?>>(json);
+ Assert.AreEqual(3, v2.Count);
+ Assert.AreEqual(1, v2["First"]);
+ Assert.AreEqual(null, v2["Second"]);
+ Assert.AreEqual(3, v2["Third"]);
+ }
}
public class UriGuidTimeSpanTestClass