diff options
author | JamesNK <james@newtonking.com> | 2011-10-01 15:10:11 +0400 |
---|---|---|
committer | JamesNK <james@newtonking.com> | 2011-10-01 15:10:11 +0400 |
commit | b5f5db5624e67fc803523bd1696a6d3a9530d508 (patch) | |
tree | 7509c50c14fbd1c21c0d9b914a96fd8fd99df97e /Src/Newtonsoft.Json.Tests | |
parent | 3fcf02a653a614ab2d58df0b0c5e099e5f233f5f (diff) |
-Improve TypeNameHandling.Auto to skip adding an unneeded type name for collection interfaces
Diffstat (limited to 'Src/Newtonsoft.Json.Tests')
-rw-r--r-- | Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs | 2 | ||||
-rw-r--r-- | Src/Newtonsoft.Json.Tests/Serialization/TypeNameHandlingTests.cs | 46 |
2 files changed, 47 insertions, 1 deletions
diff --git a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs index a83aef1..d9aade5 100644 --- a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs @@ -66,5 +66,5 @@ using System.Runtime.InteropServices; // by using the '*' as shown below:
[assembly: AssemblyVersion("4.0.3.0")]
#if !PocketPC
-[assembly: AssemblyFileVersion("4.0.3.14201")]
+[assembly: AssemblyFileVersion("4.0.3.14202")]
#endif
diff --git a/Src/Newtonsoft.Json.Tests/Serialization/TypeNameHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/TypeNameHandlingTests.cs index dc71f3f..6419380 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/TypeNameHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/TypeNameHandlingTests.cs @@ -41,6 +41,52 @@ namespace Newtonsoft.Json.Tests.Serialization {
public class TypeNameHandlingTests : TestFixtureBase
{
+ public class Wrapper
+ {
+ public IList<EmployeeReference> Array { get; set; }
+ public IDictionary<string, EmployeeReference> Dictionary { get; set; }
+ }
+
+ [Test]
+ public void sdfsdf()
+ {
+ Wrapper wrapper = new Wrapper();
+ wrapper.Array = new List<EmployeeReference>
+ {
+ new EmployeeReference()
+ };
+ wrapper.Dictionary = new Dictionary<string, EmployeeReference>
+ {
+ { "First", new EmployeeReference() }
+ };
+
+ string json = JsonConvert.SerializeObject(wrapper, Formatting.Indented, new JsonSerializerSettings
+ {
+ TypeNameHandling = TypeNameHandling.Auto
+ });
+
+ Assert.AreEqual(@"{
+ ""Array"": [
+ {
+ ""$id"": ""1"",
+ ""Name"": null,
+ ""Manager"": null
+ }
+ ],
+ ""Dictionary"": {
+ ""First"": {
+ ""$id"": ""2"",
+ ""Name"": null,
+ ""Manager"": null
+ }
+ }
+}", json);
+
+ Wrapper w2 = JsonConvert.DeserializeObject<Wrapper>(json);
+ Assert.IsInstanceOfType(typeof(List<EmployeeReference>), w2.Array);
+ Assert.IsInstanceOfType(typeof(Dictionary<string, EmployeeReference>), w2.Dictionary);
+ }
+
[Test]
public void WriteTypeNameForObjects()
{
|