This commit is contained in:
James Newton-King
2017-01-19 19:24:46 +13:00
parent 76600dcc5b
commit c4104766ed
3 changed files with 47 additions and 3 deletions
@@ -87,6 +87,40 @@ namespace Newtonsoft.Json.Tests
public const string JsonText =
@"{""strings"":[null,""Markus egger ]><[, (2nd)"",null],""dictionary"":{""Val & asd1"":1,""Val2 & asd1"":3,""Val3 & asd1"":4},""Name"":""Rick"",""Now"":""\/Date(1262301136080+1300)\/"",""BigNumber"":34123123123.121,""Address1"":{""Street"":""fff Street"",""Phone"":""(503) 814-6335"",""Entered"":""\/Date(1264025536080+1300)\/""},""Addresses"":[{""Street"":""\u001farray<address"",""Phone"":""(503) 814-6335"",""Entered"":""\/Date(1262211136080+1300)\/""},{""Street"":""array 2 address"",""Phone"":""(503) 814-6335"",""Entered"":""\/Date(1262124736080+1300)\/""}]}";
public const string JsonIndentedText =
@"{
""strings"": [
null,
""Markus egger ]><[, (2nd)"",
null
],
""dictionary"": {
""Val & asd1"": 1,
""Val2 & asd1"": 3,
""Val3 & asd1"": 4
},
""Name"": ""Rick"",
""Now"": ""/Date(1262301136080+1300)/"",
""BigNumber"": 34123123123.121,
""Address1"": {
""Street"": ""fff Street"",
""Phone"": ""(503) 814-6335"",
""Entered"": ""/Date(1264025536080+1300)/""
},
""Addresses"": [
{
""Street"": ""\u001farray<address"",
""Phone"": ""(503) 814-6335"",
""Entered"": ""/Date(1262211136080+1300)/""
},
{
""Street"": ""array 2 address"",
""Phone"": ""(503) 814-6335"",
""Entered"": ""/Date(1262124736080+1300)/""
}
]
}";
private const string JsonIsoText =
@"{""strings"":[null,""Markus egger ]><[, (2nd)"",null],""dictionary"":{""Val & asd1"":1,""Val2 & asd1"":3,""Val3 & asd1"":4},""Name"":""Rick"",""Now"":""2012-02-25T19:55:50.6095676+13:00"",""BigNumber"":34123123123.121,""Address1"":{""Street"":""fff Street"",""Phone"":""(503) 814-6335"",""Entered"":""2012-02-24T18:55:50.6095676+13:00""},""Addresses"":[{""Street"":""\u001farray<address"",""Phone"":""(503) 814-6335"",""Entered"":""2012-02-24T18:55:50.6095676+13:00""},{""Street"":""array 2 address"",""Phone"":""(503) 814-6335"",""Entered"":""2012-02-24T18:55:50.6095676+13:00""}]}";
@@ -288,6 +322,12 @@ namespace Newtonsoft.Json.Tests
await BenchmarkDeserializeMethodAsync<TestClass>(SerializeMethod.JsonNetManualAsync, JsonText);
}
[Test]
public async Task DeserializeIndentedAsync()
{
await BenchmarkDeserializeMethodAsync<TestClass>(SerializeMethod.JsonNetManualAsync, JsonIndentedText);
}
public void DeserializeTests<T>(string json)
{
BenchmarkDeserializeMethod<T>(SerializeMethod.JavaScriptSerializer, json);
+5 -1
View File
@@ -138,7 +138,9 @@ namespace Newtonsoft.Json.Tests
public static void Fail(string message = null, params object[] args)
{
if (message != null)
{
message = message.FormatWith(CultureInfo.InvariantCulture, args);
}
XAssert.True(false, message);
}
@@ -313,14 +315,16 @@ namespace Newtonsoft.Json.Tests
Assert.Contains(value, collection, message);
#else
if (!collection.Cast<object>().Any(i => i.Equals(value)))
{
throw new Exception(message ?? "Value not found in collection.");
}
#endif
}
}
public static class StringAssert
{
private readonly static Regex Regex = new Regex(@"\r\n|\n\r|\n|\r", RegexOptions.CultureInvariant);
private static readonly Regex Regex = new Regex(@"\r\n|\n\r|\n|\r", RegexOptions.CultureInvariant);
public static void AreEqual(string expected, string actual)
{
@@ -36,9 +36,9 @@ namespace Newtonsoft.Json.Serialization
/// The default serialization binder used when resolving and loading classes from type names.
/// </summary>
public class DefaultSerializationBinder :
#pragma warning disable CS0618 // Type or member is obsolete
#pragma warning disable 618
SerializationBinder,
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore 618
ISerializationBinder
{
internal static readonly DefaultSerializationBinder Instance = new DefaultSerializationBinder();