Merge branch 'master' into Move-classes-to-files-under-TestObjects
# Conflicts: # Src/Newtonsoft.Json.Tests/Converters/IsoDateTimeConverterTests.cs # Src/Newtonsoft.Json.Tests/Linq/JObjectTests.cs # Src/Newtonsoft.Json.Tests/Schema/ExtensionsTests.cs # Src/Newtonsoft.Json.Tests/Serialization/DependencyInjectionTests.cs # Src/Newtonsoft.Json.Tests/Serialization/ExtensionDataTests.cs # Src/Newtonsoft.Json.Tests/Serialization/PopulateTests.cs # Src/Newtonsoft.Json.Tests/Serialization/TypeNameHandlingTests.cs # Src/Newtonsoft.Json.Tests/TestObjects/Money/Currency.cs
This commit is contained in:
@@ -35,11 +35,7 @@ using System.Numerics;
|
||||
#endif
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -59,7 +55,6 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
{
|
||||
private const char Euro = '\u20ac';
|
||||
|
||||
#if !NETFX_CORE
|
||||
[Test]
|
||||
public void DeserializeLargeBsonObject()
|
||||
{
|
||||
@@ -72,7 +67,6 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
|
||||
Assert.AreEqual("1", (string)o["$id"]);
|
||||
}
|
||||
#endif
|
||||
|
||||
public class MyTest
|
||||
{
|
||||
@@ -1488,8 +1482,7 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
CollectionAssert.AreEquivalent(new byte[] { 72, 63, 62, 71, 92, 55 }, newObject.Data);
|
||||
}
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE)
|
||||
|
||||
public void Utf8Text()
|
||||
{
|
||||
string badText = System.IO.File.ReadAllText(@"PoisonText.txt");
|
||||
@@ -1506,7 +1499,6 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
|
||||
Assert.AreEqual(badText, (string)o["test"]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(NET20 || NET35 || PORTABLE || PORTABLE40) || NETSTANDARD1_1
|
||||
public class BigIntegerTestClass
|
||||
|
||||
@@ -30,11 +30,7 @@ using System.Numerics;
|
||||
#endif
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -33,11 +33,7 @@ using System.Data.SqlTypes;
|
||||
#endif
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -26,11 +26,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Converters;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -23,14 +23,10 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
using System;
|
||||
using Newtonsoft.Json.Converters;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -28,23 +28,17 @@ using System.Text;
|
||||
using Newtonsoft.Json.Bson;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
#if !NETFX_CORE
|
||||
using System.Data;
|
||||
#endif
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
@@ -30,11 +30,7 @@ using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -26,11 +26,7 @@
|
||||
using System;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -127,7 +123,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
Assert.AreEqual(2006, d.Year);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
[Test]
|
||||
public void SerializeFormattedDateTimeNewZealandCulture()
|
||||
{
|
||||
|
||||
@@ -25,11 +25,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -1,460 +0,0 @@
|
||||
#region License
|
||||
// Copyright (c) 2007 James Newton-King
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
|
||||
#if NETFX_CORE
|
||||
using System;
|
||||
using Newtonsoft.Json.Converters;
|
||||
#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
|
||||
using Windows.Data.Json;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Converters
|
||||
{
|
||||
[TestFixture]
|
||||
public class JsonValueConverterTests : TestFixtureBase
|
||||
{
|
||||
public class Computer
|
||||
{
|
||||
public string Cpu { get; set; }
|
||||
public List<string> Drives { get; set; }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WriteJson()
|
||||
{
|
||||
JsonObject o = JsonObject.Parse(@"{
|
||||
""CPU"": ""Intel"",
|
||||
""Drives"": [
|
||||
""DVD read/writer"",
|
||||
""500 gigabyte hard drive""
|
||||
]
|
||||
}");
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
JsonTextWriter writer = new JsonTextWriter(sw);
|
||||
|
||||
JsonValueConverter converter = new JsonValueConverter();
|
||||
converter.WriteJson(writer, o, null);
|
||||
|
||||
string json = sw.ToString();
|
||||
|
||||
Assert.AreEqual(@"{""Drives"":[""DVD read/writer"",""500 gigabyte hard drive""],""CPU"":""Intel""}", json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadJson()
|
||||
{
|
||||
string json = @"{
|
||||
""CPU"": ""Intel"",
|
||||
""Drives"": [
|
||||
""DVD read/writer"",
|
||||
""500 gigabyte hard drive""
|
||||
]
|
||||
}";
|
||||
|
||||
JsonTextReader writer = new JsonTextReader(new StringReader(json));
|
||||
|
||||
JsonValueConverter converter = new JsonValueConverter();
|
||||
JsonObject o = (JsonObject) converter.ReadJson(writer, typeof (JsonObject), null, null);
|
||||
|
||||
Assert.AreEqual(2, o.Count);
|
||||
Assert.AreEqual("Intel", o.GetNamedString("CPU"));
|
||||
Assert.AreEqual("DVD read/writer", o.GetNamedArray("Drives")[0].GetString());
|
||||
Assert.AreEqual("500 gigabyte hard drive", o.GetNamedArray("Drives")[1].GetString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadJsonComments()
|
||||
{
|
||||
string json = @"{/*comment!*/
|
||||
""CPU"": ""Intel"",/*comment!*/
|
||||
""Drives"": [/*comment!*/
|
||||
""DVD read/writer"",
|
||||
/*comment!*/""500 gigabyte hard drive""
|
||||
]/*comment!*/
|
||||
}";
|
||||
|
||||
JsonTextReader writer = new JsonTextReader(new StringReader(json));
|
||||
|
||||
JsonValueConverter converter = new JsonValueConverter();
|
||||
JsonObject o = (JsonObject) converter.ReadJson(writer, typeof (JsonObject), null, null);
|
||||
|
||||
Assert.AreEqual(2, o.Count);
|
||||
Assert.AreEqual("Intel", o.GetNamedString("CPU"));
|
||||
Assert.AreEqual("DVD read/writer", o.GetNamedArray("Drives")[0].GetString());
|
||||
Assert.AreEqual("500 gigabyte hard drive", o.GetNamedArray("Drives")[1].GetString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadJsonNullValue()
|
||||
{
|
||||
string json = "null";
|
||||
|
||||
JsonTextReader writer = new JsonTextReader(new StringReader(json));
|
||||
|
||||
JsonValueConverter converter = new JsonValueConverter();
|
||||
JsonValue v = (JsonValue) converter.ReadJson(writer, typeof (JsonValue), null, null);
|
||||
|
||||
Assert.AreEqual(JsonValueType.Null, v.ValueType);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadJsonUnsupportedValue()
|
||||
{
|
||||
string json = "undefined";
|
||||
|
||||
JsonTextReader writer = new JsonTextReader(new StringReader(json));
|
||||
|
||||
JsonValueConverter converter = new JsonValueConverter();
|
||||
|
||||
ExceptionAssert.Throws<JsonException>(() =>
|
||||
{
|
||||
converter.ReadJson(writer, typeof (JsonValue), null, null);
|
||||
}, "Unexpected or unsupported token: Undefined. Path '', line 1, position 9.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadJsonUnexpectedEndInArray()
|
||||
{
|
||||
string json = "[";
|
||||
|
||||
JsonTextReader writer = new JsonTextReader(new StringReader(json));
|
||||
|
||||
JsonValueConverter converter = new JsonValueConverter();
|
||||
|
||||
ExceptionAssert.Throws<JsonException>(() =>
|
||||
{
|
||||
converter.ReadJson(writer, typeof (JsonValue), null, null);
|
||||
}, "Unexpected end when reading JSON. Path '', line 1, position 1.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadJsonUnexpectedEndAfterComment()
|
||||
{
|
||||
string json = "[/*comment!*/";
|
||||
|
||||
JsonTextReader writer = new JsonTextReader(new StringReader(json));
|
||||
|
||||
JsonValueConverter converter = new JsonValueConverter();
|
||||
|
||||
ExceptionAssert.Throws<JsonException>(() =>
|
||||
{
|
||||
converter.ReadJson(writer, typeof (JsonValue), null, null);
|
||||
}, "Unexpected end when reading JSON. Path '', line 1, position 13.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadJsonUnexpectedEndInObject()
|
||||
{
|
||||
string json = "{'hi':";
|
||||
|
||||
JsonTextReader writer = new JsonTextReader(new StringReader(json));
|
||||
|
||||
JsonValueConverter converter = new JsonValueConverter();
|
||||
|
||||
ExceptionAssert.Throws<JsonException>(() =>
|
||||
{
|
||||
converter.ReadJson(writer, typeof (JsonValue), null, null);
|
||||
}, "Unexpected end when reading JSON. Path 'hi', line 1, position 6.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadJsonBadJsonType()
|
||||
{
|
||||
string json = "null";
|
||||
|
||||
JsonTextReader writer = new JsonTextReader(new StringReader(json));
|
||||
|
||||
JsonValueConverter converter = new JsonValueConverter();
|
||||
|
||||
ExceptionAssert.Throws<JsonException>(() =>
|
||||
{
|
||||
converter.ReadJson(writer, typeof (JsonObject), null, null);
|
||||
},
|
||||
"Could not convert 'Windows.Data.Json.JsonValue' to 'Windows.Data.Json.JsonObject'. Path '', line 1, position 4.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void JsonConvertDeserialize()
|
||||
{
|
||||
string json = @"[
|
||||
""DVD read/writer"",
|
||||
""500 gigabyte hard drive""
|
||||
]";
|
||||
|
||||
JsonArray a = JsonConvert.DeserializeObject<JsonArray>(json);
|
||||
|
||||
Assert.AreEqual(2, a.Count);
|
||||
Assert.AreEqual("DVD read/writer", a[0].GetString());
|
||||
Assert.AreEqual("500 gigabyte hard drive", a[1].GetString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void JsonConvertSerialize()
|
||||
{
|
||||
JsonArray a = JsonArray.Parse(@"[
|
||||
""DVD read/writer"",
|
||||
""500 gigabyte hard drive""
|
||||
]");
|
||||
|
||||
string json = JsonConvert.SerializeObject(a, Formatting.Indented);
|
||||
|
||||
Assert.AreEqual(@"[
|
||||
""DVD read/writer"",
|
||||
""500 gigabyte hard drive""
|
||||
]", json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializeDouble()
|
||||
{
|
||||
JsonObject o = new JsonObject();
|
||||
o["zero"] = JsonValue.CreateNumberValue(0);
|
||||
o["int"] = JsonValue.CreateNumberValue(1);
|
||||
o["smallfraction"] = JsonValue.CreateNumberValue(3.0000000000000009);
|
||||
o["double"] = JsonValue.CreateNumberValue(1.1);
|
||||
o["probablyint"] = JsonValue.CreateNumberValue(1.0);
|
||||
o["Epsilon"] = JsonValue.CreateNumberValue(double.Epsilon);
|
||||
o["MinValue"] = JsonValue.CreateNumberValue(double.MinValue);
|
||||
o["MaxValue"] = JsonValue.CreateNumberValue(double.MaxValue);
|
||||
o["NaN"] = JsonValue.CreateNumberValue(double.NaN);
|
||||
o["NegativeInfinity"] = JsonValue.CreateNumberValue(double.NegativeInfinity);
|
||||
o["PositiveInfinity"] = JsonValue.CreateNumberValue(double.PositiveInfinity);
|
||||
|
||||
string json = JsonConvert.SerializeObject(o, Formatting.Indented);
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""PositiveInfinity"": ""Infinity"",
|
||||
""NegativeInfinity"": ""-Infinity"",
|
||||
""MinValue"": -1.7976931348623157E+308,
|
||||
""double"": 1.1,
|
||||
""int"": 1,
|
||||
""zero"": 0,
|
||||
""Epsilon"": 4.94065645841247E-324,
|
||||
""MaxValue"": 1.7976931348623157E+308,
|
||||
""NaN"": ""NaN"",
|
||||
""smallfraction"": 3.0000000000000009,
|
||||
""probablyint"": 1
|
||||
}", json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeserializePerformance()
|
||||
{
|
||||
string json = @"{
|
||||
""CPU"": ""Intel"",
|
||||
""Drives"": [
|
||||
""DVD read/writer"",
|
||||
""500 gigabyte hard drive""
|
||||
]
|
||||
}";
|
||||
|
||||
Stopwatch timer = new Stopwatch();
|
||||
timer.Start();
|
||||
for (int i = 0; i < 100000; i++)
|
||||
{
|
||||
JsonObject o = JsonObject.Parse(json);
|
||||
}
|
||||
timer.Stop();
|
||||
|
||||
string winrt = timer.Elapsed.TotalSeconds.ToString();
|
||||
|
||||
timer = new Stopwatch();
|
||||
timer.Start();
|
||||
for (int i = 0; i < 100000; i++)
|
||||
{
|
||||
JObject o = JObject.Parse(json);
|
||||
}
|
||||
timer.Stop();
|
||||
|
||||
string linq = timer.Elapsed.TotalSeconds.ToString();
|
||||
|
||||
// warm up
|
||||
JsonConvert.DeserializeObject<Computer>(json);
|
||||
|
||||
timer = new Stopwatch();
|
||||
timer.Start();
|
||||
for (int i = 0; i < 100000; i++)
|
||||
{
|
||||
Computer o = JsonConvert.DeserializeObject<Computer>(json);
|
||||
}
|
||||
timer.Stop();
|
||||
|
||||
string jsonnet = timer.Elapsed.TotalSeconds.ToString();
|
||||
|
||||
Debug.WriteLine("winrt: {0}, jsonnet: {1}, jsonnet linq: {2}", winrt, jsonnet, linq);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializePerformance()
|
||||
{
|
||||
string json = @"{
|
||||
""CPU"": ""Intel"",
|
||||
""Drives"": [
|
||||
""DVD read/writer"",
|
||||
""500 gigabyte hard drive""
|
||||
]
|
||||
}";
|
||||
|
||||
JsonObject o = JsonObject.Parse(json);
|
||||
JObject o1 = JObject.Parse(json);
|
||||
Computer o2 = JsonConvert.DeserializeObject<Computer>(json);
|
||||
|
||||
Stopwatch timer = new Stopwatch();
|
||||
timer.Start();
|
||||
for (int i = 0; i < 100000; i++)
|
||||
{
|
||||
o.Stringify();
|
||||
}
|
||||
timer.Stop();
|
||||
|
||||
string winrt = timer.Elapsed.TotalSeconds.ToString();
|
||||
|
||||
timer.Start();
|
||||
for (int i = 0; i < 100000; i++)
|
||||
{
|
||||
o1.ToString(Formatting.None);
|
||||
}
|
||||
timer.Stop();
|
||||
|
||||
string linq = timer.Elapsed.TotalSeconds.ToString();
|
||||
|
||||
timer = new Stopwatch();
|
||||
timer.Start();
|
||||
for (int i = 0; i < 100000; i++)
|
||||
{
|
||||
JsonConvert.SerializeObject(o);
|
||||
}
|
||||
timer.Stop();
|
||||
|
||||
string jsonnet = timer.Elapsed.TotalSeconds.ToString();
|
||||
|
||||
Debug.WriteLine("winrt: {0}, jsonnet: {1}, jsonnet linq: {2}", winrt, jsonnet, linq);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ParseJson()
|
||||
{
|
||||
string json = @"{
|
||||
""channel"": {
|
||||
""title"": ""James Newton-King"",
|
||||
""link"": ""http://james.newtonking.com"",
|
||||
""description"": ""James Newton-King's blog."",
|
||||
""item"": [
|
||||
{
|
||||
""title"": ""Json.NET 1.3 + New license + Now on CodePlex"",
|
||||
""description"": ""Annoucing the release of Json.NET 1.3, the MIT license and the source being available on CodePlex"",
|
||||
""link"": ""http://james.newtonking.com/projects/json-net.aspx"",
|
||||
""category"": [
|
||||
""Json.NET"",
|
||||
""CodePlex""
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}";
|
||||
|
||||
// Windows.Data.Json
|
||||
// -----------------
|
||||
JsonObject jsonObject = JsonObject.Parse(json);
|
||||
string itemTitle1 = jsonObject["channel"].GetObject()["item"].GetArray()[0].GetObject()["title"].GetString();
|
||||
|
||||
// LINQ to JSON
|
||||
// ------------
|
||||
JObject jObject = JObject.Parse(json);
|
||||
string itemTitle2 = (string) jObject["channel"]["item"][0]["title"];
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateJson()
|
||||
{
|
||||
// Windows.Data.Json
|
||||
// -----------------
|
||||
JsonObject jsonObject = new JsonObject
|
||||
{
|
||||
{"CPU", JsonValue.CreateStringValue("Intel")},
|
||||
{
|
||||
"Drives", new JsonArray
|
||||
{
|
||||
JsonValue.CreateStringValue("DVD read/writer"),
|
||||
JsonValue.CreateStringValue("500 gigabyte hard drive")
|
||||
}
|
||||
}
|
||||
};
|
||||
string json1 = jsonObject.Stringify();
|
||||
|
||||
// LINQ to JSON
|
||||
// ------------
|
||||
JObject jObject = new JObject
|
||||
{
|
||||
{"CPU", "Intel"},
|
||||
{
|
||||
"Drives", new JArray
|
||||
{
|
||||
"DVD read/writer",
|
||||
"500 gigabyte hard drive"
|
||||
}
|
||||
}
|
||||
};
|
||||
string json2 = jObject.ToString();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Converting()
|
||||
{
|
||||
JsonObject jsonObject = new JsonObject
|
||||
{
|
||||
{"CPU", JsonValue.CreateStringValue("Intel")},
|
||||
{
|
||||
"Drives", new JsonArray
|
||||
{
|
||||
JsonValue.CreateStringValue("DVD read/writer"),
|
||||
JsonValue.CreateStringValue("500 gigabyte hard drive")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// convert Windows.Data.Json to LINQ to JSON
|
||||
JObject o = JObject.FromObject(jsonObject);
|
||||
|
||||
// convert LINQ to JSON to Windows.Data.Json
|
||||
JArray a = (JArray) o["Drives"];
|
||||
JsonArray jsonArray = a.ToObject<JsonArray>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,11 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -26,11 +26,7 @@
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Bson;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -31,11 +31,7 @@ using Newtonsoft.Json.Bson;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -31,11 +31,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json.Converters;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -25,11 +25,7 @@
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json.Converters;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -30,16 +30,12 @@ using Newtonsoft.Json.Utilities.LinqBridge;
|
||||
using System.Linq;
|
||||
#endif
|
||||
using System.Text;
|
||||
#if !(NETFX_CORE || DNXCORE50 || PORTABLE40)
|
||||
#if !(DNXCORE50 || PORTABLE40)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Tests.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
#if !(NET20 || NET35 || NET40 || NETFX_CORE || PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
using System.Buffers;
|
||||
#endif
|
||||
using System.Collections.Generic;
|
||||
@@ -34,11 +34,7 @@ using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Schema;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -593,7 +589,7 @@ namespace Newtonsoft.Json.Tests
|
||||
}", json);
|
||||
}
|
||||
|
||||
#if !(NET20 || NET35 || NET40 || NETFX_CORE || PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
[Test]
|
||||
public void ArrayPooling()
|
||||
{
|
||||
@@ -612,7 +608,7 @@ namespace Newtonsoft.Json.Tests
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !(NET20 || NET35 || NET40 || NETFX_CORE || PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
public class JsonArrayPool : IArrayPool<char>
|
||||
{
|
||||
public static readonly JsonArrayPool Instance = new JsonArrayPool();
|
||||
|
||||
@@ -37,11 +37,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -35,11 +35,7 @@ using System.Text;
|
||||
using System.Xml;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Documentation
|
||||
{
|
||||
public class JsonNetVsWindowsDataJsonTests
|
||||
{
|
||||
public void CreatingJson()
|
||||
{
|
||||
#if NETFX_CORE
|
||||
#region CreatingJSON
|
||||
// Windows.Data.Json
|
||||
// -----------------
|
||||
JsonObject jsonObject = new JsonObject
|
||||
{
|
||||
{"CPU", JsonValue.CreateStringValue("Intel")},
|
||||
{
|
||||
"Drives", new JsonArray
|
||||
{
|
||||
JsonValue.CreateStringValue("DVD read/writer"),
|
||||
JsonValue.CreateStringValue("500 gigabyte hard drive")
|
||||
}
|
||||
}
|
||||
};
|
||||
string json1 = jsonObject.Stringify();
|
||||
|
||||
// LINQ to JSON
|
||||
// ------------
|
||||
JObject jObject = new JObject
|
||||
{
|
||||
{"CPU", "Intel"},
|
||||
{
|
||||
"Drives", new JArray
|
||||
{
|
||||
"DVD read/writer",
|
||||
"500 gigabyte hard drive"
|
||||
}
|
||||
}
|
||||
};
|
||||
string json2 = jObject.ToString();
|
||||
#endregion
|
||||
#endif
|
||||
}
|
||||
|
||||
public void QueryingJson()
|
||||
{
|
||||
#if NETFX_CORE
|
||||
#region QueryingJSON
|
||||
string json = @"{
|
||||
'channel': {
|
||||
'title': 'James Newton-King',
|
||||
'link': 'http://james.newtonking.com',
|
||||
'description': 'James Newton-King's blog.',
|
||||
'item': [
|
||||
{
|
||||
'title': 'Json.NET 1.3 + New license + Now on CodePlex',
|
||||
'description': 'Annoucing the release of Json.NET 1.3, the MIT license and the source on CodePlex',
|
||||
'link': 'http://james.newtonking.com/projects/json-net.aspx',
|
||||
'category': [
|
||||
'Json.NET',
|
||||
'CodePlex'
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}";
|
||||
|
||||
// Windows.Data.Json
|
||||
// -----------------
|
||||
JsonObject jsonObject = JsonObject.Parse(json);
|
||||
string itemTitle1 = jsonObject["channel"].GetObject()["item"].GetArray()[0].GetObject()["title"].GetString();
|
||||
|
||||
// LINQ to JSON
|
||||
// ------------
|
||||
JObject jObject = JObject.Parse(json);
|
||||
string itemTitle2 = (string)jObject["channel"]["item"][0]["title"];
|
||||
#endregion
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Converting()
|
||||
{
|
||||
#if NETFX_CORE
|
||||
#region Converting
|
||||
JsonObject jsonObject = new JsonObject
|
||||
{
|
||||
{"CPU", JsonValue.CreateStringValue("Intel")},
|
||||
{"Drives", new JsonArray {
|
||||
JsonValue.CreateStringValue("DVD read/writer"),
|
||||
JsonValue.CreateStringValue("500 gigabyte hard drive")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// convert Windows.Data.Json to LINQ to JSON
|
||||
JObject o = JObject.FromObject(jsonObject);
|
||||
|
||||
// convert LINQ to JSON to Windows.Data.Json
|
||||
JArray a = (JArray)o["Drives"];
|
||||
JsonArray jsonArray = a.ToObject<JsonArray>();
|
||||
#endregion
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,11 +35,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -34,11 +34,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -36,11 +36,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -34,11 +34,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -34,11 +34,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -38,11 +38,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -25,11 +25,7 @@
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json.Schema;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -23,11 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -44,11 +44,7 @@ using Newtonsoft.Json.Tests.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -611,7 +607,7 @@ namespace Newtonsoft.Json.Tests
|
||||
value = null;
|
||||
Assert.AreEqual("null", JsonConvert.ToString(value));
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
value = DBNull.Value;
|
||||
Assert.AreEqual("null", JsonConvert.ToString(value));
|
||||
#endif
|
||||
@@ -908,8 +904,7 @@ namespace Newtonsoft.Json.Tests
|
||||
}
|
||||
|
||||
TestDateTimeFormat(value, new IsoDateTimeConverter());
|
||||
|
||||
#if !NETFX_CORE
|
||||
|
||||
if (value is DateTime)
|
||||
{
|
||||
Console.WriteLine(XmlConvert.ToString((DateTime)(object)value, XmlDateTimeSerializationMode.RoundtripKind));
|
||||
@@ -918,7 +913,6 @@ namespace Newtonsoft.Json.Tests
|
||||
{
|
||||
Console.WriteLine(XmlConvert.ToString((DateTimeOffset)(object)value));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !NET20
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
@@ -32,11 +32,7 @@ using Newtonsoft.Json.Linq;
|
||||
using System.Numerics;
|
||||
#endif
|
||||
using System.Text;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -35,11 +35,7 @@ using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -137,7 +133,7 @@ namespace Newtonsoft.Json.Tests
|
||||
Assert.AreEqual(1, arrayPool.FreeArrays.Count);
|
||||
}
|
||||
|
||||
#if !(NET20 || NET35 || NET40 || NETFX_CORE || PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
#if !(NET20 || NET35 || NET40 || PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
[Test]
|
||||
public void BufferErroringWithInvalidSize()
|
||||
{
|
||||
@@ -1715,7 +1711,7 @@ null//comment
|
||||
}
|
||||
}
|
||||
|
||||
#if !(PORTABLE || NETFX_CORE)
|
||||
#if !(PORTABLE)
|
||||
public struct ConvertibleInt : IConvertible
|
||||
{
|
||||
private readonly int _value;
|
||||
|
||||
@@ -34,11 +34,7 @@ using Newtonsoft.Json.Utilities.LinqBridge;
|
||||
using System.Numerics;
|
||||
#endif
|
||||
using System.Text;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -7,11 +7,7 @@ using System.Linq;
|
||||
#endif
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using TestAttribute = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
#if !(PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
using NUnit.Framework;
|
||||
using System.Web.UI;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
#if !(PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
using NUnit.Framework;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
|
||||
@@ -34,11 +34,7 @@ using System.Numerics;
|
||||
#endif
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -81,8 +77,7 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
Assert.Pass();
|
||||
}
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
|
||||
private void UpdateValueCount(IDictionary<string, int> counts, dynamic d)
|
||||
{
|
||||
string s = d.ToString();
|
||||
@@ -133,7 +128,6 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
|
||||
Console.WriteLine("Time (secs): " + sw.Elapsed.TotalSeconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void JObjectPropertyNames()
|
||||
|
||||
@@ -26,11 +26,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -435,7 +431,7 @@ Parameter name: index");
|
||||
}
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void ITypedListGetItemProperties()
|
||||
{
|
||||
|
||||
@@ -26,11 +26,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -33,11 +33,7 @@ using System.Numerics;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -47,7 +43,7 @@ using NUnit.Framework;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
using System.Web.UI;
|
||||
#endif
|
||||
#if NET20
|
||||
@@ -1263,7 +1259,7 @@ Parameter name: arrayIndex");
|
||||
}, "Can not add property Test3 to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object.");
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void IBindingListSortDirection()
|
||||
{
|
||||
@@ -1587,7 +1583,7 @@ Parameter name: arrayIndex");
|
||||
Assert.AreEqual("Name2", value);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void WriteObjectNullDBNullValue()
|
||||
{
|
||||
@@ -1699,7 +1695,7 @@ Parameter name: arrayIndex");
|
||||
}, "Unexpected end of content while loading JObject. Path 'short.error.code', line 6, position 14.");
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void GetProperties()
|
||||
{
|
||||
|
||||
@@ -33,11 +33,7 @@ using Newtonsoft.Json.Utilities.LinqBridge;
|
||||
using System.Linq;
|
||||
#endif
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -65,7 +61,7 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
Assert.AreEqual(p, p.Value.Parent);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void ListChanged()
|
||||
{
|
||||
|
||||
@@ -23,11 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -24,11 +24,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -26,11 +26,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -30,11 +30,7 @@ using System.Numerics;
|
||||
#endif
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -1149,7 +1145,7 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
Assert.IsTrue(a.DeepEquals(a2));
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void Clone()
|
||||
{
|
||||
|
||||
@@ -29,11 +29,7 @@ using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
#endif
|
||||
using System.Text;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -32,11 +32,7 @@ using Newtonsoft.Json.Tests.TestObjects;
|
||||
using System.Numerics;
|
||||
#endif
|
||||
using System.Text;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -154,7 +150,7 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
Assert.AreEqual("Pie", v.Value);
|
||||
Assert.AreEqual(JTokenType.String, v.Type);
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
v.Value = DBNull.Value;
|
||||
Assert.AreEqual(DBNull.Value, v.Value);
|
||||
Assert.AreEqual(JTokenType.Null, v.Type);
|
||||
@@ -498,7 +494,7 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE)
|
||||
#if !(PORTABLE)
|
||||
[Test]
|
||||
public void ConvertsToBoolean()
|
||||
{
|
||||
|
||||
@@ -31,11 +31,7 @@ using System.Numerics;
|
||||
#endif
|
||||
using Newtonsoft.Json.Linq.JsonPath;
|
||||
using Newtonsoft.Json.Tests.Bson;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -26,11 +26,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq.JsonPath;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -28,11 +28,7 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Linq.JsonPath;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -27,11 +27,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -32,11 +32,7 @@ using System.Linq;
|
||||
#endif
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if !(DNXCORE50 || NETFX_CORE || PORTABLE40 || PORTABLE40 || NET20)
|
||||
#if !(DNXCORE50 || PORTABLE40 || PORTABLE40 || NET20)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
@@ -81,7 +81,6 @@
|
||||
<Compile Include="Converters\DataTableConverterTests.cs" />
|
||||
<Compile Include="Converters\DiscriminatedUnionConverterTests.cs" />
|
||||
<Compile Include="Converters\ExpandoObjectConverterTests.cs" />
|
||||
<Compile Include="Converters\JsonValueConverterTests.cs" />
|
||||
<Compile Include="Converters\KeyValuePairConverterTests.cs" />
|
||||
<Compile Include="Converters\ObjectIdConverterTests.cs" />
|
||||
<Compile Include="Converters\RegexConverterTests.cs" />
|
||||
|
||||
@@ -108,7 +108,6 @@
|
||||
<Compile Include="Converters\BinaryConverterTests.cs" />
|
||||
<Compile Include="Converters\DiscriminatedUnionConverterTests.cs" />
|
||||
<Compile Include="Converters\ExpandoObjectConverterTests.cs" />
|
||||
<Compile Include="Converters\JsonValueConverterTests.cs" />
|
||||
<Compile Include="Converters\KeyValuePairConverterTests.cs" />
|
||||
<Compile Include="Converters\RegexConverterTests.cs" />
|
||||
<Compile Include="Converters\DataTableConverterTests.cs" />
|
||||
|
||||
@@ -111,7 +111,6 @@
|
||||
<Compile Include="Converters\BinaryConverterTests.cs" />
|
||||
<Compile Include="Converters\DiscriminatedUnionConverterTests.cs" />
|
||||
<Compile Include="Converters\ExpandoObjectConverterTests.cs" />
|
||||
<Compile Include="Converters\JsonValueConverterTests.cs" />
|
||||
<Compile Include="Converters\KeyValuePairConverterTests.cs" />
|
||||
<Compile Include="Converters\RegexConverterTests.cs" />
|
||||
<Compile Include="Converters\DataTableConverterTests.cs" />
|
||||
@@ -223,7 +222,6 @@
|
||||
<Compile Include="Documentation\Samples\Xml\ConvertXmlToJson.cs" />
|
||||
<Compile Include="Documentation\Samples\Xml\ConvertXmlToJsonForceArray.cs" />
|
||||
<Compile Include="Documentation\TraceWriterTests.cs" />
|
||||
<Compile Include="Documentation\JsonNetVsWindowsDataJsonTests.cs" />
|
||||
<Compile Include="Documentation\PerformanceTests.cs" />
|
||||
<Compile Include="Documentation\JsonSchemaTests.cs" />
|
||||
<Compile Include="Documentation\ReadingAndWritingJsonTests.cs" />
|
||||
|
||||
@@ -112,7 +112,6 @@
|
||||
<Compile Include="Converters\BinaryConverterTests.cs" />
|
||||
<Compile Include="Converters\DiscriminatedUnionConverterTests.cs" />
|
||||
<Compile Include="Converters\ExpandoObjectConverterTests.cs" />
|
||||
<Compile Include="Converters\JsonValueConverterTests.cs" />
|
||||
<Compile Include="Converters\KeyValuePairConverterTests.cs" />
|
||||
<Compile Include="Converters\RegexConverterTests.cs" />
|
||||
<Compile Include="Converters\DataTableConverterTests.cs" />
|
||||
|
||||
@@ -111,7 +111,6 @@
|
||||
<Compile Include="Converters\BinaryConverterTests.cs" />
|
||||
<Compile Include="Converters\DiscriminatedUnionConverterTests.cs" />
|
||||
<Compile Include="Converters\ExpandoObjectConverterTests.cs" />
|
||||
<Compile Include="Converters\JsonValueConverterTests.cs" />
|
||||
<Compile Include="Converters\KeyValuePairConverterTests.cs" />
|
||||
<Compile Include="Converters\RegexConverterTests.cs" />
|
||||
<Compile Include="Converters\DataTableConverterTests.cs" />
|
||||
|
||||
@@ -59,7 +59,6 @@
|
||||
<Compile Include="Converters\ExpandoObjectConverterTests.cs" />
|
||||
<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" />
|
||||
@@ -69,7 +68,6 @@
|
||||
<Compile Include="DemoTests.cs" />
|
||||
<Compile Include="Documentation\ConditionalPropertiesTests.cs" />
|
||||
<Compile Include="Documentation\ConvertingJsonAndXmlTests.cs" />
|
||||
<Compile Include="Documentation\JsonNetVsWindowsDataJsonTests.cs" />
|
||||
<Compile Include="Documentation\JsonSchemaTests.cs" />
|
||||
<Compile Include="Documentation\LinqToJsonTests.cs" />
|
||||
<Compile Include="Documentation\PerformanceTests.cs" />
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if !(NET20 || NET35 || NET40 || NETFX_CORE || PORTABLE40 || DNXCORE50)
|
||||
#if !(NET20 || NET35 || NET40 || PORTABLE40 || DNXCORE50)
|
||||
using System.Xml;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
@@ -39,8 +39,6 @@ using System.Security;
|
||||
[assembly: AssemblyTitle("Json.NET Tests Portable .NET 4.0")]
|
||||
#elif PORTABLE
|
||||
[assembly: AssemblyTitle("Json.NET Tests Portable")]
|
||||
#elif NETFX_CORE
|
||||
[assembly: AssemblyTitle("Json.NET Tests WinRT")]
|
||||
#elif NET20
|
||||
[assembly: AssemblyTitle("Json.NET Tests .NET 2.0")]
|
||||
#elif NET35
|
||||
|
||||
@@ -26,11 +26,7 @@
|
||||
#pragma warning disable 618
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -42,7 +38,7 @@ using Newtonsoft.Json.Linq;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
using System.Data;
|
||||
|
||||
#endif
|
||||
@@ -208,7 +204,7 @@ namespace Newtonsoft.Json.Tests.Schema
|
||||
#if !NET20
|
||||
GenerateSchemaAndSerializeFromType(new NullableDateTimeTestClass());
|
||||
#endif
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
GenerateSchemaAndSerializeFromType(new DataSet());
|
||||
#endif
|
||||
GenerateSchemaAndSerializeFromType(new object());
|
||||
@@ -216,7 +212,7 @@ namespace Newtonsoft.Json.Tests.Schema
|
||||
GenerateSchemaAndSerializeFromType("Hi");
|
||||
GenerateSchemaAndSerializeFromType(new DateTime(2000, 12, 29, 23, 59, 0, DateTimeKind.Utc));
|
||||
GenerateSchemaAndSerializeFromType(TimeSpan.FromTicks(1000000));
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
GenerateSchemaAndSerializeFromType(DBNull.Value);
|
||||
#endif
|
||||
GenerateSchemaAndSerializeFromType(new JsonPropertyWithHandlingValues());
|
||||
|
||||
@@ -25,11 +25,7 @@
|
||||
|
||||
#pragma warning disable 618
|
||||
using System;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -33,11 +33,7 @@ using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -97,7 +93,7 @@ namespace Newtonsoft.Json.Tests.Schema
|
||||
Assert.IsTrue(o.IsValid(schema));
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void Generate_DefaultValueAttributeTestClass()
|
||||
{
|
||||
@@ -316,7 +312,7 @@ namespace Newtonsoft.Json.Tests.Schema
|
||||
Assert.IsTrue(v.IsValid(schema));
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void GenerateSchemaForISerializable()
|
||||
{
|
||||
@@ -331,7 +327,7 @@ namespace Newtonsoft.Json.Tests.Schema
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void GenerateSchemaForDBNull()
|
||||
{
|
||||
@@ -380,7 +376,7 @@ namespace Newtonsoft.Json.Tests.Schema
|
||||
generator.UndefinedSchemaIdHandling = UndefinedSchemaIdHandling.UseTypeName;
|
||||
generator.ContractResolver = new CustomDirectoryInfoMapper
|
||||
{
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50)
|
||||
#if !(PORTABLE || DNXCORE50)
|
||||
IgnoreSerializableAttribute = true
|
||||
#endif
|
||||
};
|
||||
@@ -464,7 +460,7 @@ namespace Newtonsoft.Json.Tests.Schema
|
||||
serializer.Converters.Add(new IsoDateTimeConverter());
|
||||
serializer.ContractResolver = new CustomDirectoryInfoMapper
|
||||
{
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50)
|
||||
#if !(PORTABLE || DNXCORE50)
|
||||
IgnoreSerializableInterface = true
|
||||
#endif
|
||||
};
|
||||
@@ -484,7 +480,7 @@ namespace Newtonsoft.Json.Tests.Schema
|
||||
generator.UndefinedSchemaIdHandling = UndefinedSchemaIdHandling.UseTypeName;
|
||||
generator.ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
{
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
IgnoreSerializableAttribute = true
|
||||
#endif
|
||||
};
|
||||
@@ -529,7 +525,7 @@ namespace Newtonsoft.Json.Tests.Schema
|
||||
}", json);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void GenerateSchemaSerializable()
|
||||
{
|
||||
|
||||
@@ -25,11 +25,7 @@
|
||||
|
||||
#pragma warning disable 618
|
||||
using Newtonsoft.Json.Schema;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -25,11 +25,7 @@
|
||||
|
||||
#pragma warning disable 618
|
||||
using Newtonsoft.Json.Schema;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 618
|
||||
#if !(DNXCORE50 || NETFX_CORE)
|
||||
#if !(DNXCORE50)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
@@ -29,11 +29,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Schema;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -30,11 +30,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Schema;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -26,11 +26,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
+2
-6
@@ -26,11 +26,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -106,7 +102,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
string json = o.ToString();
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || PORTABLE40)
|
||||
#if !(PORTABLE || PORTABLE40)
|
||||
#pragma warning disable 618
|
||||
[Test]
|
||||
public void MemberSearchFlags()
|
||||
|
||||
@@ -29,11 +29,7 @@ using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -28,11 +28,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -569,7 +565,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}", startingWithB);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || PORTABLE40)
|
||||
#if !(PORTABLE || PORTABLE40)
|
||||
#pragma warning disable 618
|
||||
[Test]
|
||||
public void SerializeCompilerGeneratedMembers()
|
||||
|
||||
@@ -27,16 +27,12 @@ using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
#if !(NET20 || NET35 || NETFX_CORE || PORTABLE || DNXCORE50)
|
||||
#if !(NET20 || NET35 || PORTABLE || DNXCORE50)
|
||||
using System.Runtime.Serialization.Json;
|
||||
#endif
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -278,7 +274,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
{
|
||||
EmitDefaultValueClass c = new EmitDefaultValueClass();
|
||||
|
||||
#if !(NET20 || NET35 || NETFX_CORE || PORTABLE)
|
||||
#if !(NET20 || NET35 || PORTABLE)
|
||||
DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(EmitDefaultValueClass));
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if !(NET40 || NET35 || NET20 || DNXCORE50 || PORTABLE || PORTABLE40 || NETFX_CORE)
|
||||
#if !(NET40 || NET35 || NET20 || DNXCORE50 || PORTABLE || PORTABLE40)
|
||||
using Autofac;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
@@ -37,11 +37,7 @@ using Autofac.Core;
|
||||
using Autofac.Core.Activators.Reflection;
|
||||
using Microsoft.FSharp.Collections;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50)
|
||||
#if !(PORTABLE || DNXCORE50)
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
@@ -34,11 +34,7 @@ using Newtonsoft.Json.Utilities.LinqBridge;
|
||||
#else
|
||||
using System.Linq;
|
||||
#endif
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -37,11 +37,7 @@ using System.Text;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if !(NET35 || NET20 || NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(NET35 || NET20 || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -31,11 +31,7 @@ using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Converters;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -30,11 +30,7 @@ using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if !(NET35 || NET20 || NETFX_CORE || DNXCORE50)
|
||||
#if !(NET35 || NET20 || DNXCORE50)
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -30,11 +30,7 @@ using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -23,11 +23,7 @@
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -47,11 +47,7 @@ using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Events;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -307,7 +303,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
public class NameValueCollectionTestClass
|
||||
{
|
||||
public NameValueCollection Collection { get; set; }
|
||||
@@ -1678,7 +1674,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual(1, (int)((JObject)o.Data[2])["one"]);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
[Test]
|
||||
public void SerializeArrayAsArrayList()
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ using System.Collections.Generic;
|
||||
#if !(NET20 || NET35 || PORTABLE) || NETSTANDARD1_1
|
||||
using System.Numerics;
|
||||
#endif
|
||||
#if !(NET20 || NETFX_CORE || DNXCORE50)
|
||||
#if !(NET20 || DNXCORE50)
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Configuration;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -42,11 +42,7 @@ using System.Web.Script.Serialization;
|
||||
#endif
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -89,7 +85,7 @@ using Newtonsoft.Json.Utilities.LinqBridge;
|
||||
#else
|
||||
using System.Linq;
|
||||
#endif
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
using System.Drawing;
|
||||
|
||||
#endif
|
||||
@@ -739,7 +735,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual("Name!", c2.Name);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50 || NET20)
|
||||
#if !(DNXCORE50 || NET20)
|
||||
[MetadataType(typeof(CustomerValidation))]
|
||||
public partial class CustomerWithMetadataType
|
||||
{
|
||||
@@ -1205,7 +1201,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
serializer.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
|
||||
Assert.AreEqual(ConstructorHandling.AllowNonPublicDefaultConstructor, serializer.ConstructorHandling);
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
serializer.Context = new StreamingContext(StreamingContextStates.Other);
|
||||
Assert.AreEqual(new StreamingContext(StreamingContextStates.Other), serializer.Context);
|
||||
#endif
|
||||
@@ -1276,7 +1272,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
serializer.TraceWriter = traceWriter;
|
||||
Assert.AreEqual(traceWriter, serializer.TraceWriter);
|
||||
|
||||
#if !(PORTABLE || PORTABLE40 || NETFX_CORE || NET20 || DNXCORE50)
|
||||
#if !(PORTABLE || PORTABLE40 || NET20 || DNXCORE50)
|
||||
#pragma warning disable 618
|
||||
serializer.TypeNameAssemblyFormat = FormatterAssemblyStyle.Full;
|
||||
Assert.AreEqual(FormatterAssemblyStyle.Full, serializer.TypeNameAssemblyFormat);
|
||||
@@ -1314,7 +1310,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
settings.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
|
||||
Assert.AreEqual(ConstructorHandling.AllowNonPublicDefaultConstructor, settings.ConstructorHandling);
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
settings.Context = new StreamingContext(StreamingContextStates.Other);
|
||||
Assert.AreEqual(new StreamingContext(StreamingContextStates.Other), settings.Context);
|
||||
#endif
|
||||
@@ -1391,7 +1387,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
settings.TraceWriter = traceWriter;
|
||||
Assert.AreEqual(traceWriter, settings.TraceWriter);
|
||||
|
||||
#if !(PORTABLE || PORTABLE40 || NETFX_CORE || NET20 || DNXCORE50)
|
||||
#if !(PORTABLE || PORTABLE40 || NET20 || DNXCORE50)
|
||||
#pragma warning disable 618
|
||||
settings.TypeNameAssemblyFormat = FormatterAssemblyStyle.Full;
|
||||
Assert.AreEqual(FormatterAssemblyStyle.Full, settings.TypeNameAssemblyFormat);
|
||||
@@ -1442,7 +1438,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
serializerProxy.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;
|
||||
Assert.AreEqual(ConstructorHandling.AllowNonPublicDefaultConstructor, serializerProxy.ConstructorHandling);
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
serializerProxy.Context = new StreamingContext(StreamingContextStates.Other);
|
||||
Assert.AreEqual(new StreamingContext(StreamingContextStates.Other), serializerProxy.Context);
|
||||
#endif
|
||||
@@ -1513,7 +1509,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
serializerProxy.TraceWriter = traceWriter;
|
||||
Assert.AreEqual(traceWriter, serializerProxy.TraceWriter);
|
||||
|
||||
#if !(PORTABLE || PORTABLE40 || NETFX_CORE || NET20 || DNXCORE50)
|
||||
#if !(PORTABLE || PORTABLE40 || NET20 || DNXCORE50)
|
||||
#pragma warning disable 618
|
||||
serializerProxy.TypeNameAssemblyFormat = FormatterAssemblyStyle.Full;
|
||||
Assert.AreEqual(FormatterAssemblyStyle.Full, serializerProxy.TypeNameAssemblyFormat);
|
||||
@@ -1534,7 +1530,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual(TypeNameHandling.All, serializerProxy.TypeNameHandling);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
#if !(PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
[Test]
|
||||
public void DeserializeISerializableIConvertible()
|
||||
{
|
||||
@@ -1793,8 +1789,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.IsNotNull(deserialized.foo);
|
||||
Assert.AreEqual("value", deserialized.foo.bar);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE)
|
||||
|
||||
[Test]
|
||||
public void ConversionOperator()
|
||||
{
|
||||
@@ -1818,7 +1813,6 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
var deserialize = jsonSerializer.Deserialize(new StreamReader(ms), typeof(Dictionary<DictionaryKeyCast, int>));
|
||||
stopWatch.Stop();
|
||||
}
|
||||
#endif
|
||||
|
||||
internal class DictionaryKeyCast
|
||||
{
|
||||
@@ -2218,7 +2212,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual(executorObject2.clientGetResultFunction, "ClientBanSubsCB");
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
[Test]
|
||||
public void HashtableDeserialization()
|
||||
{
|
||||
@@ -2436,7 +2430,7 @@ keyword such as type of business.""
|
||||
{
|
||||
string json = @"[""vvv\/vvv\tvvv\""vvv\bvvv\nvvv\rvvv\\vvv\fvvv""]";
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
List<string> javaScriptSerializerResult = javaScriptSerializer.Deserialize<List<string>>(json);
|
||||
#endif
|
||||
@@ -2448,7 +2442,7 @@ keyword such as type of business.""
|
||||
|
||||
Assert.AreEqual(1, jsonNetResult.Count);
|
||||
Assert.AreEqual(dataContractResult[0], jsonNetResult[0]);
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
Assert.AreEqual(javaScriptSerializerResult[0], jsonNetResult[0]);
|
||||
#endif
|
||||
}
|
||||
@@ -2659,7 +2653,7 @@ keyword such as type of business.""
|
||||
string json = JsonConvert.SerializeObject(new ConverableMembers(), Formatting.Indented);
|
||||
|
||||
string expected = null;
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50)
|
||||
#if !(PORTABLE || DNXCORE50)
|
||||
expected = @"{
|
||||
""String"": ""string"",
|
||||
""Int32"": 2147483647,
|
||||
@@ -2699,7 +2693,7 @@ keyword such as type of business.""
|
||||
ConverableMembers c = JsonConvert.DeserializeObject<ConverableMembers>(json);
|
||||
Assert.AreEqual("string", c.String);
|
||||
Assert.AreEqual(double.MaxValue, c.Double);
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
Assert.AreEqual(DBNull.Value, c.DBNull);
|
||||
#endif
|
||||
}
|
||||
@@ -3543,7 +3537,7 @@ keyword such as type of business.""
|
||||
Assert.AreEqual("titleId", n.FidOrder[n.FidOrder.Count - 1]);
|
||||
}
|
||||
|
||||
#if !(NET20 || NETFX_CORE || DNXCORE50)
|
||||
#if !(NET20 || DNXCORE50)
|
||||
[MetadataType(typeof(OptInClassMetadata))]
|
||||
public class OptInClass
|
||||
{
|
||||
@@ -3925,7 +3919,7 @@ To fix this error either change the JSON to a JSON object (e.g. {""name"":""valu
|
||||
Path '', line 1, position 1.");
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50)
|
||||
#if !(PORTABLE || DNXCORE50)
|
||||
[Test]
|
||||
public void CannotDeserializeArrayIntoSerializable()
|
||||
{
|
||||
@@ -4043,7 +4037,7 @@ Path '', line 1, position 1.");
|
||||
{
|
||||
ContractResolver = new DefaultContractResolver
|
||||
{
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
IgnoreSerializableAttribute = true
|
||||
#endif
|
||||
}
|
||||
@@ -4060,7 +4054,7 @@ Path '', line 1, position 1.");
|
||||
{
|
||||
ContractResolver = new DefaultContractResolver
|
||||
{
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
IgnoreSerializableAttribute = true
|
||||
#endif
|
||||
}
|
||||
@@ -4077,7 +4071,7 @@ Path '', line 1, position 1.");
|
||||
{
|
||||
ContractResolver = new DefaultContractResolver
|
||||
{
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
IgnoreSerializableAttribute = true
|
||||
#endif
|
||||
}
|
||||
@@ -4094,7 +4088,7 @@ Path '', line 1, position 1.");
|
||||
{
|
||||
ContractResolver = new DefaultContractResolver
|
||||
{
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
IgnoreSerializableAttribute = true
|
||||
#endif
|
||||
}
|
||||
@@ -4868,7 +4862,7 @@ Path '', line 1, position 1.");
|
||||
Assert.AreEqual("value", newModelStateDictionary["key"]);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
public class ISerializableTestObject : ISerializable
|
||||
{
|
||||
internal string _stringValue;
|
||||
@@ -5357,7 +5351,7 @@ Path '', line 1, position 1.");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
public class XmlNodeTestObject
|
||||
{
|
||||
public XmlDocument Document { get; set; }
|
||||
@@ -5395,7 +5389,7 @@ Path '', line 1, position 1.");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void SerializeDeserializeXmlNodeProperties()
|
||||
{
|
||||
@@ -5723,7 +5717,7 @@ Path '', line 1, position 1.");
|
||||
Assert.AreEqual(0, z[1].Prop1.Length);
|
||||
}
|
||||
|
||||
#if !(NET20 || NETFX_CORE || DNXCORE50)
|
||||
#if !(NET20 || DNXCORE50)
|
||||
public class StringDictionaryTestClass
|
||||
{
|
||||
public StringDictionary StringDictionaryProperty { get; set; }
|
||||
@@ -6050,7 +6044,7 @@ Path '', line 1, position 1.");
|
||||
Assert.AreEqual(meh.IDontWork, "meh");
|
||||
}
|
||||
|
||||
#if !(NET20 || NETFX_CORE || DNXCORE50)
|
||||
#if !(NET20 || DNXCORE50)
|
||||
[DataContract]
|
||||
public struct StructISerializable : ISerializable
|
||||
{
|
||||
@@ -6793,7 +6787,7 @@ Path '', line 1, position 1.");
|
||||
}
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void SerializeException1()
|
||||
{
|
||||
@@ -7020,7 +7014,7 @@ Path '', line 1, position 1.");
|
||||
Assert.AreEqual(-3, StaticTestClass.z);
|
||||
}
|
||||
|
||||
#if !(NET20 || NETFX_CORE || DNXCORE50)
|
||||
#if !(NET20 || DNXCORE50)
|
||||
[Test]
|
||||
public void DeserializeDecimalsWithCulture()
|
||||
{
|
||||
@@ -7181,7 +7175,7 @@ Path '', line 1, position 1.");
|
||||
ExceptionAssert.Throws<JsonSerializationException>(() => { List<int> numbers = JsonConvert.DeserializeObject<List<int>>(json); }, "Error converting value {null} to type 'System.Int32'. Path '[3]', line 5, position 6.");
|
||||
}
|
||||
|
||||
#if !(PORTABLE || NETFX_CORE)
|
||||
#if !(PORTABLE)
|
||||
public class ConvertableIntTestClass
|
||||
{
|
||||
public ConvertibleInt Integer { get; set; }
|
||||
@@ -7540,7 +7534,7 @@ Path '', line 1, position 1.");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
[Test]
|
||||
public void MetroBlogPost()
|
||||
{
|
||||
@@ -7934,7 +7928,7 @@ Path '', line 1, position 1.");
|
||||
Assert.AreEqual("", s);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void SerializeAndDeserializeWithAttributes()
|
||||
{
|
||||
@@ -8095,7 +8089,7 @@ Path '', line 1, position 1.");
|
||||
ExceptionAssert.Throws<JsonReaderException>(() => { s.Deserialize<Dictionary<string, int>>(new JsonTextReader(new StringReader(json))); }, "Additional text encountered after finished reading JSON content: {. Path '', line 1, position 7.");
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void DeserializeException()
|
||||
{
|
||||
@@ -8337,7 +8331,7 @@ Path '', line 1, position 1.");
|
||||
|
||||
Action doStuff = () => { obj = JsonConvert.DeserializeObject<MyTuple<int>>(json); };
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
doStuff();
|
||||
Assert.AreEqual(500, obj.Item1);
|
||||
#else
|
||||
@@ -8368,7 +8362,7 @@ Path '', line 1, position 1.");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || NET35 || NET20 || PORTABLE40 || DNXCORE50)
|
||||
#if !(PORTABLE || NET35 || NET20 || PORTABLE40 || DNXCORE50)
|
||||
[Test]
|
||||
public void SerializeTupleWithSerializableAttribute()
|
||||
{
|
||||
@@ -8395,29 +8389,6 @@ Path '', line 1, position 1.");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NETFX_CORE
|
||||
[Test]
|
||||
public void SerializeWinRTJsonObject()
|
||||
{
|
||||
var o = Windows.Data.Json.JsonObject.Parse(@"{
|
||||
""CPU"": ""Intel"",
|
||||
""Drives"": [
|
||||
""DVD read/writer"",
|
||||
""500 gigabyte hard drive""
|
||||
]
|
||||
}");
|
||||
|
||||
string json = JsonConvert.SerializeObject(o, Formatting.Indented);
|
||||
Assert.AreEqual(@"{
|
||||
""Drives"": [
|
||||
""DVD read/writer"",
|
||||
""500 gigabyte hard drive""
|
||||
],
|
||||
""CPU"": ""Intel""
|
||||
}", json);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !NET20
|
||||
[Test]
|
||||
public void RoundtripOfDateTimeOffset()
|
||||
@@ -8636,7 +8607,7 @@ Path '', line 1, position 1.");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
[Serializable]
|
||||
#endif
|
||||
[DataContract]
|
||||
@@ -8665,7 +8636,7 @@ Path '', line 1, position 1.");
|
||||
|
||||
Assert.AreEqual(@"{""First"":""One"",""Second"":2}", json);
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
DefaultContractResolver r = new DefaultContractResolver();
|
||||
r.IgnoreSerializableAttribute = false;
|
||||
|
||||
@@ -8781,7 +8752,7 @@ Path '', line 1, position 1.");
|
||||
Assert.AreEqual(1234567890.123456m, d);
|
||||
}
|
||||
|
||||
#if !(PORTABLE || DNXCORE50 || NETFX_CORE || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void DontSerializeStaticFields()
|
||||
{
|
||||
@@ -8945,7 +8916,7 @@ Path '', line 1, position 1.");
|
||||
]", json);
|
||||
}
|
||||
|
||||
#if !(PORTABLE || PORTABLE40 || NETFX_CORE || DNXCORE50)
|
||||
#if !(PORTABLE || PORTABLE40 || DNXCORE50)
|
||||
[Test]
|
||||
public void SerializeDictionaryWithStructKey()
|
||||
{
|
||||
@@ -9036,7 +9007,7 @@ Path '', line 1, position 1.");
|
||||
Assert.AreEqual(jane, john.Spouse);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || NET35 || NET20 || PORTABLE || PORTABLE40)
|
||||
#if !(NET35 || NET20 || PORTABLE || PORTABLE40)
|
||||
[Test]
|
||||
public void TypeConverterOnInterface()
|
||||
{
|
||||
@@ -9102,7 +9073,7 @@ Path '', line 1, position 1.");
|
||||
ParticipantEntity deserializedProduct = JsonConvert.DeserializeObject<ParticipantEntity>(json);
|
||||
}
|
||||
|
||||
#if !(PORTABLE || NETFX_CORE)
|
||||
#if !(PORTABLE)
|
||||
public class ConvertibleId : IConvertible
|
||||
{
|
||||
public int Value;
|
||||
@@ -9634,7 +9605,7 @@ Path '', line 1, position 1.");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
[Test]
|
||||
public void MailMessageConverterTest()
|
||||
{
|
||||
|
||||
@@ -32,11 +32,7 @@ using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -116,7 +112,6 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}, @"Cannot preserve reference to array or readonly list, or list created from a non-default constructor: System.String[][]. Path '$values', line 3, position 14.");
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
[Test]
|
||||
public void SerializeDeserialize_DictionaryContextContainsGuid_DeserializesItemAsGuid()
|
||||
{
|
||||
@@ -143,7 +138,6 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
|
||||
Assert.AreEqual(someValue, deserializedObject[contextKey]);
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void DeserializeGuid()
|
||||
|
||||
@@ -28,11 +28,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -26,11 +26,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -28,11 +28,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -33,11 +33,7 @@ using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -27,11 +27,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -155,7 +151,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}", json);
|
||||
}
|
||||
|
||||
#if !(PORTABLE || DNXCORE50 || NETFX_CORE || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
public class MainClass : ISerializable
|
||||
{
|
||||
public ChildClass Child { get; set; }
|
||||
@@ -313,13 +309,8 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
|
||||
int IEqualityComparer.GetHashCode(object obj)
|
||||
{
|
||||
#if !(NETFX_CORE)
|
||||
// put objects in a bucket based on their reference
|
||||
return RuntimeHelpers.GetHashCode(obj);
|
||||
#else
|
||||
// put all objects in the same bucket so ReferenceEquals is called on all
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,7 @@ using System.Text;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Utilities;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -35,11 +35,7 @@ using Newtonsoft.Json.Utilities.LinqBridge;
|
||||
#else
|
||||
using System.Linq;
|
||||
#endif
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -37,11 +37,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -276,7 +272,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}", json);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50)
|
||||
#if !(PORTABLE || DNXCORE50)
|
||||
public class SerializationEventContextTestObject
|
||||
{
|
||||
public string TestMember { get; set; }
|
||||
|
||||
@@ -36,11 +36,7 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -26,11 +26,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
|
||||
@@ -10,11 +10,7 @@ using System.Numerics;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters;
|
||||
using System.Text;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -45,7 +41,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
[TestFixture]
|
||||
public class TraceWriterTests : TestFixtureBase
|
||||
{
|
||||
#if !(PORTABLE || DNXCORE50 || NETFX_CORE || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void DiagnosticsTraceWriterTest()
|
||||
{
|
||||
@@ -674,7 +670,7 @@ Newtonsoft.Json Error: 0 : Error!
|
||||
Assert.IsTrue(traceWriter.TraceRecords[9].Message.StartsWith("Finished deserializing System.Collections.Generic.List`1[System.Object]. Path '$values'"));
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void DeserializeISerializable()
|
||||
{
|
||||
|
||||
@@ -44,11 +44,7 @@ using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using Newtonsoft.Json.Tests.TestObjects.Organization;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
@@ -361,7 +357,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual("Name!", ((EmployeeReference)employee).Name);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50)
|
||||
#if !(PORTABLE || DNXCORE50)
|
||||
[Test]
|
||||
public void DeserializeTypeNameFromGacAssembly()
|
||||
{
|
||||
@@ -1243,7 +1239,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
CollectionAssert.AreEquivalent(data, d);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
[Test]
|
||||
public void ISerializableTypeNameHandlingTest()
|
||||
{
|
||||
@@ -1308,7 +1304,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
ContractResolver = new DefaultContractResolver
|
||||
{
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50)
|
||||
#if !(PORTABLE || DNXCORE50)
|
||||
IgnoreSerializableAttribute = true
|
||||
#endif
|
||||
}
|
||||
@@ -1339,7 +1335,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
public override void BindToName(Type serializedType, out string assemblyName, out string typeName)
|
||||
{
|
||||
assemblyName = "AssemblyName";
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
typeName = ":::" + serializedType.Name.ToUpper(CultureInfo.InvariantCulture) + ":::";
|
||||
#else
|
||||
typeName = ":::" + serializedType.Name.ToUpper() + ":::";
|
||||
@@ -1784,7 +1780,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
[Test]
|
||||
public void SerializeDeserialize_DictionaryContextContainsGuid_DeserializesItemAsGuid()
|
||||
{
|
||||
@@ -2079,7 +2075,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
public string SomeProperty { get; set; }
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
public class ParentParent
|
||||
{
|
||||
[JsonProperty(ItemTypeNameHandling = TypeNameHandling.Auto)]
|
||||
@@ -2147,7 +2143,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
public class SerializableWrapper
|
||||
{
|
||||
public object Content { get; set; }
|
||||
|
||||
@@ -30,18 +30,14 @@ using System.IO;
|
||||
using System.Linq;
|
||||
#endif
|
||||
using System.Text;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using Test = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Test = Xunit.FactAttribute;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
#else
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
#if !(NETFX_CORE || NET20 || NET35 || DNXCORE50)
|
||||
#if !(NET20 || NET35 || DNXCORE50)
|
||||
using System.Runtime.Serialization.Json;
|
||||
#endif
|
||||
using Newtonsoft.Json.Serialization;
|
||||
@@ -63,7 +59,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
nonSerializedField = "Error"
|
||||
};
|
||||
|
||||
#if !(NETFX_CORE || NET20 || NET35 || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(NET20 || NET35 || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
MemoryStream ms = new MemoryStream();
|
||||
DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(SerializableType));
|
||||
dataContractJsonSerializer.WriteObject(ms, serializableType);
|
||||
@@ -79,7 +75,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
{
|
||||
ContractResolver = new DefaultContractResolver
|
||||
{
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
IgnoreSerializableAttribute = false
|
||||
#endif
|
||||
}
|
||||
@@ -88,7 +84,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual(expected, json);
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Test]
|
||||
public void SerializeInheritedType()
|
||||
{
|
||||
@@ -118,7 +114,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[Serializable]
|
||||
#else
|
||||
[JsonObject(MemberSerialization.Fields)]
|
||||
@@ -142,7 +138,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
set { privateField = value; }
|
||||
}
|
||||
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
#if !(PORTABLE || DNXCORE50 || PORTABLE40)
|
||||
[NonSerialized]
|
||||
#else
|
||||
[JsonIgnore]
|
||||
|
||||
@@ -36,12 +36,7 @@ using System.Runtime.Serialization.Json;
|
||||
#endif
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
#if NETFX_CORE
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using TestFixture = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestClassAttribute;
|
||||
using TestMethod = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestMethodAttribute;
|
||||
using SetUp = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.TestInitializeAttribute;
|
||||
#elif DNXCORE50
|
||||
#if DNXCORE50
|
||||
using Xunit;
|
||||
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
|
||||
using XAssert = Xunit.Assert;
|
||||
@@ -63,7 +58,7 @@ namespace Newtonsoft.Json.Tests
|
||||
{
|
||||
public static IEnumerable<ConstructorInfo> GetConstructors(Type type)
|
||||
{
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
return type.GetConstructors();
|
||||
#else
|
||||
return type.GetTypeInfo().DeclaredConstructors;
|
||||
@@ -72,7 +67,7 @@ namespace Newtonsoft.Json.Tests
|
||||
|
||||
public static PropertyInfo GetProperty(Type type, string name)
|
||||
{
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
return type.GetProperty(name);
|
||||
#else
|
||||
return type.GetTypeInfo().GetDeclaredProperty(name);
|
||||
@@ -81,7 +76,7 @@ namespace Newtonsoft.Json.Tests
|
||||
|
||||
public static FieldInfo GetField(Type type, string name)
|
||||
{
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
return type.GetField(name);
|
||||
#else
|
||||
return type.GetTypeInfo().GetDeclaredField(name);
|
||||
@@ -90,7 +85,7 @@ namespace Newtonsoft.Json.Tests
|
||||
|
||||
public static MethodInfo GetMethod(Type type, string name)
|
||||
{
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
return type.GetMethod(name);
|
||||
#else
|
||||
return type.GetTypeInfo().GetDeclaredMethod(name);
|
||||
@@ -274,7 +269,7 @@ namespace Newtonsoft.Json.Tests
|
||||
protected void TestSetup()
|
||||
#endif
|
||||
{
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
//CultureInfo turkey = CultureInfo.CreateSpecificCulture("tr");
|
||||
//Thread.CurrentThread.CurrentCulture = turkey;
|
||||
//Thread.CurrentThread.CurrentUICulture = turkey;
|
||||
@@ -297,25 +292,11 @@ namespace Newtonsoft.Json.Tests
|
||||
}
|
||||
}
|
||||
|
||||
#if NETFX_CORE
|
||||
public static class Console
|
||||
{
|
||||
public static void WriteLine(params object[] args)
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public static class CustomAssert
|
||||
{
|
||||
public static void IsInstanceOfType(Type t, object instance)
|
||||
{
|
||||
#if NETFX_CORE
|
||||
if (!instance.GetType().IsAssignableFrom(t))
|
||||
throw new Exception("Not instance of type");
|
||||
#else
|
||||
Assert.IsInstanceOf(t, instance);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void Contains(IList collection, object value)
|
||||
@@ -325,7 +306,7 @@ namespace Newtonsoft.Json.Tests
|
||||
|
||||
public static void Contains(IList collection, object value, string message)
|
||||
{
|
||||
#if !(NETFX_CORE || DNXCORE50)
|
||||
#if !(DNXCORE50)
|
||||
Assert.Contains(value, collection, message);
|
||||
#else
|
||||
if (!collection.Cast<object>().Any(i => i.Equals(value)))
|
||||
|
||||
@@ -34,7 +34,7 @@ using System.Linq;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50)
|
||||
#if !(PORTABLE || DNXCORE50)
|
||||
[Serializable]
|
||||
public class AnswerFilterModel
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Newtonsoft.Json.Tests.TestObjects
|
||||
public ulong ULong = long.MaxValue;
|
||||
public double Double = double.MaxValue;
|
||||
public float Float = float.MaxValue;
|
||||
#if !(NETFX_CORE || PORTABLE || DNXCORE50)
|
||||
#if !(PORTABLE || DNXCORE50)
|
||||
public DBNull DBNull = DBNull.Value;
|
||||
#endif
|
||||
public bool Bool = true;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user