This commit is contained in:
James Newton-King
2014-06-26 16:13:36 +12:00
parent d30b802977
commit b66724ed4e
5 changed files with 51 additions and 1 deletions
@@ -35,7 +35,6 @@ using System.Text;
using Newtonsoft.Json.Converters;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
#if !NETFX_CORE
using NUnit.Framework;
#else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
#endif
namespace Newtonsoft.Json.Tests.Converters
{
[TestFixture]
public class KeyValuePairConverterTests : TestFixtureBase
{
[Test]
public void SerializeUsingInternalConverter()
{
DefaultContractResolver contractResolver = new DefaultContractResolver();
JsonObjectContract contract = (JsonObjectContract) contractResolver.ResolveContract(typeof (KeyValuePair<string, int>));
Assert.AreEqual(typeof(KeyValuePairConverter), contract.InternalConverter.GetType());
IList<KeyValuePair<string, int>> values = new List<KeyValuePair<string, int>>
{
new KeyValuePair<string, int>("123", 123),
new KeyValuePair<string, int>("456", 456)
};
string json = JsonConvert.SerializeObject(values, Formatting.Indented);
Console.WriteLine(json);
}
}
}
@@ -786,6 +786,9 @@ namespace Newtonsoft.Json.Tests.Linq
string newRole = newHotness.Roles[0];
// Admin
Assert.AreEqual("Admin", oldRole);
Assert.AreEqual("Admin", newRole);
}
[Test]
@@ -69,6 +69,7 @@
<Compile Include="Converters\IsoDateTimeConverterTests.cs" />
<Compile Include="Converters\JavaScriptDateTimeConverterTests.cs" />
<Compile Include="Converters\JsonValueConverterTests.cs" />
<Compile Include="Converters\KeyValuePairConverterTests.cs" />
<Compile Include="Converters\ObjectIdConverterTests.cs" />
<Compile Include="Converters\RegexConverterTests.cs" />
<Compile Include="Converters\StringEnumConverterTests.cs" />
@@ -24,6 +24,8 @@
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
namespace Newtonsoft.Json.Tests.TestObjects
@@ -68,4 +70,9 @@ namespace Newtonsoft.Json.Tests.TestObjects
public string Department { get; set; }
public string JobTitle { get; set; }
}
public class Manager : Employee
{
public IList<Employee> Employees { get; set; }
}
}