-Tests
This commit is contained in:
@@ -35,7 +35,6 @@ using System.Text;
|
|||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
#if !NETFX_CORE
|
#if !NETFX_CORE
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
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];
|
string newRole = newHotness.Roles[0];
|
||||||
// Admin
|
// Admin
|
||||||
|
|
||||||
|
Assert.AreEqual("Admin", oldRole);
|
||||||
|
Assert.AreEqual("Admin", newRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|||||||
@@ -69,6 +69,7 @@
|
|||||||
<Compile Include="Converters\IsoDateTimeConverterTests.cs" />
|
<Compile Include="Converters\IsoDateTimeConverterTests.cs" />
|
||||||
<Compile Include="Converters\JavaScriptDateTimeConverterTests.cs" />
|
<Compile Include="Converters\JavaScriptDateTimeConverterTests.cs" />
|
||||||
<Compile Include="Converters\JsonValueConverterTests.cs" />
|
<Compile Include="Converters\JsonValueConverterTests.cs" />
|
||||||
|
<Compile Include="Converters\KeyValuePairConverterTests.cs" />
|
||||||
<Compile Include="Converters\ObjectIdConverterTests.cs" />
|
<Compile Include="Converters\ObjectIdConverterTests.cs" />
|
||||||
<Compile Include="Converters\RegexConverterTests.cs" />
|
<Compile Include="Converters\RegexConverterTests.cs" />
|
||||||
<Compile Include="Converters\StringEnumConverterTests.cs" />
|
<Compile Include="Converters\StringEnumConverterTests.cs" />
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace Newtonsoft.Json.Tests.TestObjects
|
namespace Newtonsoft.Json.Tests.TestObjects
|
||||||
@@ -68,4 +70,9 @@ namespace Newtonsoft.Json.Tests.TestObjects
|
|||||||
public string Department { get; set; }
|
public string Department { get; set; }
|
||||||
public string JobTitle { get; set; }
|
public string JobTitle { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Manager : Employee
|
||||||
|
{
|
||||||
|
public IList<Employee> Employees { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user