-Tests line endings

This commit is contained in:
James Newton-King
2014-09-12 23:34:20 +12:00
parent a09c2110e8
commit 99df43eb4d
46 changed files with 434 additions and 414 deletions
@@ -56,7 +56,7 @@ namespace Newtonsoft.Json.Tests.Serialization
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""name"": ""Name!"",
""birthDate"": ""2000-11-20T23:55:44Z"",
""lastModified"": ""2000-11-20T23:55:44Z""
@@ -72,7 +72,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(person.Name, deserializedPerson.Name);
json = JsonConvert.SerializeObject(person, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""Name!"",
""BirthDate"": ""2000-11-20T23:55:44Z"",
""LastModified"": ""2000-11-20T23:55:44Z""
@@ -113,7 +113,7 @@ namespace Newtonsoft.Json.Tests.Serialization
ContractResolver = new CamelCasePropertyNamesContractResolver { DefaultMembersSearchFlags = BindingFlags.NonPublic | BindingFlags.Instance }
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""_privateString"": ""PrivateString!"",
""i"": 0,
""_internalString"": ""InternalString!""
@@ -166,7 +166,7 @@ namespace Newtonsoft.Json.Tests.Serialization
// ]
//}
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""name"": ""Widget"",
""expiryDate"": ""2010-12-20T18:01:00Z"",
""price"": 9.99,
@@ -192,7 +192,7 @@ namespace Newtonsoft.Json.Tests.Serialization
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""explicit"": false,
""text"": ""Text!"",
""integer"": 2147483647,
@@ -217,7 +217,7 @@ namespace Newtonsoft.Json.Tests.Serialization
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""first"": ""Value1!"",
""second"": ""Value2!""
}", json);
@@ -499,7 +499,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string iPersonJson = JsonConvert.SerializeObject(employee, Formatting.Indented,
new JsonSerializerSettings { ContractResolver = new IPersonContractResolver() });
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""FirstName"": ""Maurice"",
""LastName"": ""Moss"",
""BirthDate"": ""1977-12-30T01:01:01Z""
@@ -535,13 +535,13 @@ namespace Newtonsoft.Json.Tests.Serialization
// "BookPrice": 16.19
// }
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""AuthorName"": ""Brandon Sanderson"",
""AuthorAge"": 34,
""AuthorCountry"": ""United States of America""
}", startingWithA);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""BookName"": ""The Gathering Storm"",
""BookPrice"": 16.19
}", startingWithB);
@@ -568,7 +568,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string skipCompilerGeneratedJson = JsonConvert.SerializeObject(structTest, Formatting.Indented,
new JsonSerializerSettings { ContractResolver = skipCompilerGeneratedResolver });
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""StringField"": ""Field"",
""IntField"": 1,
""StringProperty"": ""Property"",
@@ -584,7 +584,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string includeCompilerGeneratedJson = JsonConvert.SerializeObject(structTest, Formatting.Indented,
new JsonSerializerSettings { ContractResolver = includeCompilerGeneratedResolver });
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""StringField"": ""Field"",
""IntField"": 1,
""<StringProperty>k__BackingField"": ""Property"",
@@ -99,7 +99,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting.Indented,
new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Include });
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Company"": ""Acme Ltd."",
""Amount"": 50.0,
""Paid"": false,
@@ -126,7 +126,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting.Indented,
new JsonSerializerSettings { });
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Company"": ""Acme Ltd."",
""Amount"": 50.0,
""Paid"": false,
@@ -139,7 +139,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting.Indented,
new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore });
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Company"": ""Acme Ltd."",
""Amount"": 50.0
}", ignored);
@@ -295,7 +295,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""IntInclude"": 0,
""IntDefault"": 0
}", json);
@@ -305,7 +305,7 @@ namespace Newtonsoft.Json.Tests.Serialization
DefaultValueHandling = DefaultValueHandling.Ignore
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""IntInclude"": 0
}", json);
@@ -314,7 +314,7 @@ namespace Newtonsoft.Json.Tests.Serialization
DefaultValueHandling = DefaultValueHandling.Include
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""IntInclude"": 0,
""IntDefault"": 0
}", json);
@@ -80,7 +80,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(d.ChildObject, values["ChildObject"]);
string json = JsonConvert.SerializeObject(dynamicObject, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Explicit"": true,
""Decimal"": 99.9,
""Int"": 1,
@@ -125,7 +125,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string dynamicChildObjectTypeName = ReflectionUtils.GetTypeName(typeof(DynamicChildObject), FormatterAssemblyStyle.Full, null);
string expandoObjectTypeName = ReflectionUtils.GetTypeName(typeof(ExpandoObject), FormatterAssemblyStyle.Full, null);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$type"": """ + expandoObjectTypeName + @""",
""Text"": ""Text!"",
""Integer"": 2147483647,
@@ -267,7 +267,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Console.WriteLine(json);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Explicit"": false,
""Text"": ""Text!"",
""Int"": 2147483647
@@ -290,7 +290,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Console.WriteLine(json);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Explicit"": false,
""Text"": ""Text!"",
""DynamicChildObject"": null,
@@ -317,7 +317,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Console.WriteLine(json);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Text"": ""Text!"",
""Int"": 2147483647
}", json);
@@ -123,7 +123,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}
}";
Assert.AreEqual(expected, json);
StringAssert.AreEqual(expected, json);
}
[Test]
@@ -213,7 +213,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}
}";
Assert.AreEqual(expected, json);
StringAssert.AreEqual(expected, json);
}
[Test]
@@ -337,7 +337,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(e, settings);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$id"": ""1"",
""entitySetName"": ""Folder"",
""entityContainerName"": ""DataServicesTestDatabaseEntities"",
@@ -401,7 +401,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(e, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$id"": ""1"",
""EntitySetName"": ""Folder"",
""EntityContainerName"": ""DataServicesTestDatabaseEntities"",
@@ -65,7 +65,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""Name!"",
""Key!"": ""Value!""
}", json);
@@ -392,7 +392,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting = Formatting.Indented
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$id"": ""1"",
""Name"": ""Name!"",
""Test"": 1,
@@ -520,7 +520,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting = Formatting.Indented
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$type"": ""Newtonsoft.Json.Tests.Serialization.ExtensionDataTests+PublicExtensionDataAttributeTestClass, Newtonsoft.Json.Tests"",
""Name"": ""Name!"",
""Test"": {
@@ -44,7 +44,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
1,
2,
3
@@ -63,7 +63,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
1,
2,
3
@@ -56,7 +56,7 @@ namespace Newtonsoft.Json.Tests.Serialization
});
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
""One"",
""II"",
""3""
@@ -114,7 +114,7 @@ namespace Newtonsoft.Json.Tests.Serialization
});
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
""One"",
""II"",
""3""
@@ -162,7 +162,7 @@ namespace Newtonsoft.Json.Tests.Serialization
});
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
""One"",
""II"",
""3""
@@ -216,7 +216,7 @@ namespace Newtonsoft.Json.Tests.Serialization
});
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
""3"",
""II"",
""One""
@@ -325,7 +325,7 @@ namespace Newtonsoft.Json.Tests.Serialization
});
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
""3"",
""II"",
""One""
@@ -416,7 +416,7 @@ namespace Newtonsoft.Json.Tests.Serialization
});
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""1"": ""One"",
""2"": ""II"",
""3"": ""3""
@@ -309,7 +309,7 @@ namespace Newtonsoft.Json.Tests.Serialization
CustomReadOnlyDictionary<string, int> dic = new CustomReadOnlyDictionary<string, int>(d);
string json = JsonConvert.SerializeObject(dic, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""one"": 1,
""two"": 2
}", json);
@@ -353,7 +353,7 @@ namespace Newtonsoft.Json.Tests.Serialization
CustomReadOnlyCollection<int> list = new CustomReadOnlyCollection<int>(l);
string json = JsonConvert.SerializeObject(list, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
1,
2,
3
@@ -442,7 +442,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(list, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
{
""Key"": ""key1"",
""Value"": {
@@ -528,7 +528,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(v1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""First"": 1,
""Second"": null,
""Third"": 3
@@ -558,7 +558,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string originalJson = JsonConvert.SerializeObject(go, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Components"": {
""Key!"": {}
},
@@ -663,7 +663,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""NonReadOnlyList"": [
1
],
@@ -783,7 +783,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(aa, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Before"": ""Before!"",
""Coordinates"": [
[
@@ -1088,7 +1088,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting = Formatting.Indented
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$id"": ""1"",
""$values"": [
{
@@ -1142,7 +1142,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting = Formatting.Indented
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$type"": ""System.Collections.Generic.List`1[[Newtonsoft.Json.Tests.TestObjects.Event1[,], Newtonsoft.Json.Tests]], mscorlib"",
""$values"": [
{
@@ -1281,7 +1281,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(name, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""personsName"": ""The Idiot in Next To Me"",
""pNumbers"": [
{
@@ -1420,7 +1420,7 @@ namespace Newtonsoft.Json.Tests.Serialization
// }
//]
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
{
""Name"": ""Product 1"",
""ExpiryDate"": ""2000-12-29T00:00:00Z"",
@@ -1482,7 +1482,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
1,
2,
3,
@@ -681,8 +681,8 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(null, v.Value);
Assert.AreEqual(JTokenType.String, v.Type);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""title"": null
}", output);
}
@@ -954,7 +954,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = AssertSerializeDeserializeEqual(baseWith);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""JustAProperty"": ""JustAProperty2!"",
""Virtual"": ""Virtual2!"",
""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"",
@@ -984,7 +984,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Console.WriteLine(json);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"",
""VirtualSub"": ""Virtual2!"",
""WithDataMemberBase"": ""WithDataMember2!"",
@@ -1010,7 +1010,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = AssertSerializeDeserializeEqual(baseWith);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""JustAProperty"": ""JustAProperty2!"",
""JustAProperty2"": ""JustAProperty!"",
""Virtual"": ""Virtual2!"",
@@ -1040,7 +1040,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = AssertSerializeDeserializeEqual(baseWith);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""JustAProperty"": ""JustAProperty2!"",
""Virtual"": ""Virtual2!"",
""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"",
@@ -1215,7 +1215,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypedSubHashtable p = JsonConvert.DeserializeObject(value, typeof(TypedSubHashtable)) as TypedSubHashtable;
Assert.AreEqual("01/24/2010 12:00:00", p.Hash["ExpiryDate"].ToString());
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
""01/24/2010 12:00:00""
]", p.Hash["UntypedArray"].ToString());
}
@@ -1671,7 +1671,7 @@ keyword such as type of business.""
}";
#endif
Assert.AreEqual(expected, json);
StringAssert.AreEqual(expected, json);
ConverableMembers c = JsonConvert.DeserializeObject<ConverableMembers>(json);
Assert.AreEqual("string", c.String);
@@ -1747,7 +1747,7 @@ keyword such as type of business.""
TimeSpan ts = new TimeSpan(00, 23, 59, 1);
string json = JsonConvert.SerializeObject(new ClassWithTimeSpan { TimeSpanField = ts }, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""TimeSpanField"": ""23:59:01""
}", json);
@@ -2062,7 +2062,7 @@ keyword such as type of business.""
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""FirstName"": ""Bob"",
""MiddleName"": ""Cosmo"",
""LastName"": ""Smith"",
@@ -2447,7 +2447,7 @@ keyword such as type of business.""
string json = JsonConvert.SerializeObject(o, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""DefaultValueHandlingIncludeProperty"": ""Default!"",
""DefaultValueHandlingPopulateProperty"": ""Default!"",
""NullValueHandlingIncludeProperty"": null,
@@ -2458,7 +2458,7 @@ keyword such as type of business.""
json = JsonConvert.SerializeObject(o, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""DefaultValueHandlingIncludeProperty"": ""Default!"",
""DefaultValueHandlingPopulateProperty"": ""Default!"",
""NullValueHandlingIncludeProperty"": null
@@ -2554,7 +2554,7 @@ keyword such as type of business.""
string json = JsonConvert.SerializeObject(optInClass, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""James NK"",
""Age"": 26
}", json);
@@ -2614,7 +2614,7 @@ keyword such as type of business.""
c.NotIncluded = "Hi";
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""_name"": ""Jeff"",
""_age"": 26,
""Rank"": 10,
@@ -2771,7 +2771,7 @@ keyword such as type of business.""
string json = JsonConvert.SerializeObject(content, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Children"": [
{
""Children"": null,
@@ -2939,7 +2939,9 @@ Path '', line 1, position 1.");
{
string json = @"[]";
ExceptionAssert.Throws<JsonSerializationException>(() => { JsonConvert.DeserializeObject<DynamicDictionary>(json); }, @"Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Newtonsoft.Json.Tests.Linq.DynamicDictionary' because the type requires a JSON object (e.g. {""name"":""value""}) to deserialize correctly.
ExceptionAssert.Throws<JsonSerializationException>(
() => { JsonConvert.DeserializeObject<DynamicDictionary>(json); },
@"Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Newtonsoft.Json.Tests.Linq.DynamicDictionary' because the type requires a JSON object (e.g. {""name"":""value""}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {""name"":""value""}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '', line 1, position 1.");
}
@@ -2986,9 +2988,9 @@ Path '', line 1, position 1.");
}
catch (JsonSerializationException ex)
{
Assert.IsTrue(ex.Message.StartsWith(@"Cannot deserialize the current JSON object (e.g. {""name"":""value""}) into type 'System.Collections.Generic.List`1[Newtonsoft.Json.Tests.TestObjects.Person]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path ''"));
Assert.IsTrue(ex.Message.StartsWith(@"Cannot deserialize the current JSON object (e.g. {""name"":""value""}) into type 'System.Collections.Generic.List`1[Newtonsoft.Json.Tests.TestObjects.Person]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly." + Environment.NewLine +
@"To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object." + Environment.NewLine +
@"Path ''"));
}
}
@@ -3103,7 +3105,7 @@ Path ''"));
{
ConstructorReadonlyFields c1 = new ConstructorReadonlyFields("String!", int.MaxValue);
string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""A"": ""String!"",
""B"": 2147483647
}", json);
@@ -3126,7 +3128,7 @@ Path ''"));
string json = JsonConvert.SerializeObject(structTest, Formatting.Indented);
Console.WriteLine(json);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""StringField"": ""StringField"",
""IntField"": 10,
""StringProperty"": ""StringProperty!"",
@@ -3149,7 +3151,7 @@ Path ''"));
f.Bars.Add(new Bar { Id = 2 });
string json = JsonConvert.SerializeObject(f, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Bars"": [
0,
1,
@@ -3172,7 +3174,7 @@ Path ''"));
dictionary.Add(new Guid("C2594C02-EBA1-426A-AA87-8DD8871350B0"), 2);
string json = JsonConvert.SerializeObject(dictionary, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""f60eaee0-ae47-488e-b330-59527b742d77"": 1,
""c2594c02-eba1-426a-aa87-8dd8871350b0"": 2
}", json);
@@ -3187,7 +3189,7 @@ Path ''"));
string json = JsonConvert.SerializeObject(dictionary, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Newtonsoft.Json.Tests.TestObjects.Person"": 1,
""Newtonsoft.Json.Tests.TestObjects.Person"": 2
}", json);
@@ -3307,7 +3309,7 @@ Path ''"));
wagePerson.Name = "Jim Bob";
string json = JsonConvert.SerializeObject(personPropertyClass, Formatting.Indented);
Assert.AreEqual(
StringAssert.AreEqual(
@"{
""Person"": {
""HourlyWage"": 12.50,
@@ -3430,7 +3432,7 @@ Path ''"));
string json = g.ToJson();
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""MyProperty"": ""some value"",
""TheItems"": [
{
@@ -3541,7 +3543,7 @@ Path ''"));
B value = new B();
string json = JsonConvert.SerializeObject(value, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""B2"": null,
""A1"": null,
""B3"": null,
@@ -3929,7 +3931,7 @@ To fix this error either change the environment to be fully trusted, change the
ISerializableTestObject o = new ISerializableTestObject("String!", int.MinValue, dateTimeOffset, person);
string json = JsonConvert.SerializeObject(o, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""stringValue"": ""String!"",
""intValue"": -2147483648,
""dateTimeOffsetValue"": """ + dateTimeOffsetText + @""",
@@ -3986,7 +3988,7 @@ To fix this error either change the environment to be fully trusted, change the
{
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""stringValue"": ""String!"",
""intValue"": -2147483648,
""dateTimeOffsetValue"": """ + dateTimeOffsetText + @""",
@@ -4052,7 +4054,7 @@ To fix this error either change the environment to be fully trusted, change the
{
AA myA = new AA(2);
string json = JsonConvert.SerializeObject(myA, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""AA_field1"": 2,
""AA_property1"": 2,
""AA_property2"": 2,
@@ -4062,7 +4064,7 @@ To fix this error either change the environment to be fully trusted, change the
BB myB = new BB(3, 4);
json = JsonConvert.SerializeObject(myB, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""BB_field1"": 4,
""BB_field2"": 4,
""AA_field1"": 3,
@@ -4270,7 +4272,7 @@ To fix this error either change the environment to be fully trusted, change the
}
}
}";
Assert.AreEqual(expected, json);
StringAssert.AreEqual(expected, json);
XNodeTestObject newTestObject = JsonConvert.DeserializeObject<XNodeTestObject>(json);
Assert.AreEqual(testObject.Document.ToString(), newTestObject.Document.ToString());
@@ -4295,7 +4297,7 @@ To fix this error either change the environment to be fully trusted, change the
""root"": ""hehe, root""
}
}";
Assert.AreEqual(expected, json);
StringAssert.AreEqual(expected, json);
XmlNodeTestObject newTestObject = JsonConvert.DeserializeObject<XmlNodeTestObject>(json);
Assert.AreEqual(testObject.Document.InnerXml, newTestObject.Document.InnerXml);
@@ -4511,7 +4513,7 @@ To fix this error either change the environment to be fully trusted, change the
string json = JsonConvert.SerializeObject(dictionary, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""First!"": ""First"",
""Second!"": ""Second""
}", json);
@@ -4527,7 +4529,7 @@ To fix this error either change the environment to be fully trusted, change the
{
string jsonText = JsonConvert.SerializeObject(new double?[] { 2.4, 4.3, null }, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
2.4,
4.3,
null
@@ -4560,7 +4562,7 @@ To fix this error either change the environment to be fully trusted, change the
"III"
}, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
""One"",
""2"",
""III""
@@ -4648,7 +4650,7 @@ To fix this error either change the environment to be fully trusted, change the
string json = JsonConvert.SerializeObject(testStruct, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""MyInt"": 2147483647
}", json);
@@ -4739,7 +4741,7 @@ To fix this error either change the environment to be fully trusted, change the
{
string json = JsonConvert.SerializeObject(new DerivedEvent(), Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""event"": ""derived""
}", json);
}
@@ -4756,7 +4758,7 @@ To fix this error either change the environment to be fully trusted, change the
expando.Complex.DateTime = new DateTime(2000, 12, 20, 18, 55, 0, DateTimeKind.Utc);
string json = JsonConvert.SerializeObject(expando, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Int"": 1,
""Decimal"": 99.9,
""Complex"": {
@@ -5065,7 +5067,7 @@ To fix this error either change the environment to be fully trusted, change the
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Enumerable"": [
""One"",
""Two"",
@@ -5087,7 +5089,7 @@ To fix this error either change the environment to be fully trusted, change the
string json = JsonConvert.SerializeObject(i, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": null
}", json);
}
@@ -5364,7 +5366,7 @@ To fix this error either change the environment to be fully trusted, change the
string result = JsonConvert.SerializeObject(cc, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""virtualMember"": ""2010-12-31T00:00:00Z"",
""newMemberWithProperty"": null
}", result);
@@ -5390,7 +5392,7 @@ To fix this error either change the environment to be fully trusted, change the
c1.Categories.Add("two");
string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Title"": ""blah"",
""Categories"": [
""one"",
@@ -5425,7 +5427,7 @@ To fix this error either change the environment to be fully trusted, change the
c1.Categories.Add("two", 2);
string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Title"": ""blah"",
""Categories"": {
""one"": 1,
@@ -5516,7 +5518,7 @@ To fix this error either change the environment to be fully trusted, change the
NonSerialized = "NonSerialized!"
}, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""DerivedClassValue"": ""DerivedClassValue!"",
""BaseClassValue"": ""BaseClassValue!""
}", json);
@@ -5527,7 +5529,7 @@ To fix this error either change the environment to be fully trusted, change the
CollectionDerivedClassValue = "CollectionDerivedClassValue!"
}, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""CollectionDerivedClassValue"": ""CollectionDerivedClassValue!"",
""BaseClassValue"": ""BaseClassValue!""
}", json);
@@ -5568,7 +5570,7 @@ To fix this error either change the environment to be fully trusted, change the
PrivateMembersClassWithAttributes c1 = new PrivateMembersClassWithAttributes("privateString!", "internalString!", "readonlyString!");
string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""_privateString"": ""privateString!"",
""_readonlyString"": ""readonlyString!"",
""_internalString"": ""internalString!""
@@ -5635,7 +5637,7 @@ To fix this error either change the environment to be fully trusted, change the
DerivedType d = new DerivedType();
string json = JsonConvert.SerializeObject(d, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""dinosaur"": null,
""dog"": null,
""cat"": null,
@@ -5688,7 +5690,7 @@ To fix this error either change the environment to be fully trusted, change the
UriGuidTimeSpanTestClass c1 = new UriGuidTimeSpanTestClass();
string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Guid"": ""00000000-0000-0000-0000-000000000000"",
""NullableGuid"": null,
""TimeSpan"": ""00:00:00"",
@@ -5717,7 +5719,7 @@ To fix this error either change the environment to be fully trusted, change the
};
string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Guid"": ""1924129c-f7e0-40f3-9607-9939c531395a"",
""NullableGuid"": ""9e9f3adf-e017-4f72-91e0-617ebe85967d"",
""TimeSpan"": ""1.00:00:00"",
@@ -5827,7 +5829,7 @@ To fix this error either change the environment to be fully trusted, change the
ContractResolver = contractResolver
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""x"": 2147483647,
""y"": 2,
""z"": 3
@@ -5864,7 +5866,7 @@ To fix this error either change the environment to be fully trusted, change the
ContractResolver = contractResolver
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""x"": 2147483647,
""y"": 2,
""z"": 3
@@ -6002,7 +6004,7 @@ To fix this error either change the environment to be fully trusted, change the
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Integer"": 1,
""NullableInteger1"": 2,
""NullableInteger2"": null
@@ -6099,7 +6101,7 @@ To fix this error either change the environment to be fully trusted, change the
string jsonString = JsonConvert.SerializeObject(expected, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""SourceTypeID"": ""d8220a4b-75b1-4b7a-8112-b7bdae956a45"",
""BrokerID"": ""951663c4-924e-4c86-a57a-7ed737501dbd"",
""Latitude"": 33.657145,
@@ -6363,7 +6365,7 @@ To fix this error either change the environment to be fully trusted, change the
Converters = { new MetroStringConverter() },
Formatting = Formatting.Indented
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
"":::NAME:::"": "":::APPLE:::"",
"":::EXPIRYDATE:::"": ""2012-04-01T00:00:00"",
"":::PRICE:::"": 3.99,
@@ -6389,7 +6391,7 @@ To fix this error either change the environment to be fully trusted, change the
Formatting = Formatting.Indented
});
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
"":::GRAY:::"",
"":::GRAY:::"",
"":::GRAY:::"",
@@ -6542,7 +6544,7 @@ To fix this error either change the environment to be fully trusted, change the
Formatting = Formatting.Indented
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""DefaultProperty"": null,
""AllowNullProperty"": null
}", json);
@@ -6605,7 +6607,7 @@ To fix this error either change the environment to be fully trusted, change the
string json = JsonConvert.SerializeObject(dic1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""2000-12-12T12:12:12+00:00"": 1,
""2013-12-12T12:12:12+00:00"": 2
}", json);
@@ -6631,7 +6633,7 @@ To fix this error either change the environment to be fully trusted, change the
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""\/Date(976623132000+0000)\/"": 1,
""\/Date(1386850332000+0000)\/"": 2
}", json);
@@ -6655,7 +6657,7 @@ To fix this error either change the environment to be fully trusted, change the
string json = JsonConvert.SerializeObject(dic1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""2000-12-12T12:12:12Z"": 1,
""2013-12-12T12:12:12Z"": 2
}", json);
@@ -6681,7 +6683,7 @@ To fix this error either change the environment to be fully trusted, change the
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""\/Date(976623132000)\/"": 1,
""\/Date(1386850332000)\/"": 2
}", json);
@@ -6772,7 +6774,7 @@ To fix this error either change the environment to be fully trusted, change the
// ]
//}
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""EventName"": ""Blackadder III"",
""Venue"": ""Gryphon Theatre"",
""Performances"": [
@@ -6823,7 +6825,7 @@ To fix this error either change the environment to be fully trusted, change the
//Console.WriteLine(Encoding.UTF8.GetString(ms.ToArray()));
string json = JsonConvert.SerializeObject(dataContract, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""DataMemberAttribute"": ""Value!"",
""IgnoreDataMemberAndDataMemberAttribute"": ""Value!""
}", json);
@@ -6837,7 +6839,7 @@ To fix this error either change the environment to be fully trusted, change the
};
json = JsonConvert.SerializeObject(poco, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""NoAttribute"": ""Value!"",
""DataMemberAttribute"": ""Value!""
}", json);
@@ -6988,7 +6990,7 @@ To fix this error either change the environment to be fully trusted, change the
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""key"": 123,
""value"": ""test value""
}", json);
@@ -7227,7 +7229,7 @@ To fix this error either change the environment to be fully trusted, change the
FloatFormatHandling = FloatFormatHandling.DefaultValue
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Object"": 0.0,
""Float"": 0.0,
""Double"": 0.0,
@@ -7252,7 +7254,7 @@ To fix this error either change the environment to be fully trusted, change the
Culture = new CultureInfo("en-NZ")
});
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
""2000 p.m."",
""2000 p.m.""
]", json);
@@ -7272,7 +7274,7 @@ To fix this error either change the environment to be fully trusted, change the
DateFormatString = @"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffK"
});
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
""2000-12-12T12:12:12.000Z"",
""2000-12-12T12:12:12.000+01:00""
]", json);
@@ -7304,7 +7306,7 @@ To fix this error either change the environment to be fully trusted, change the
string json = sw.ToString();
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
""2000 p.m."",
""2000 p.m.""
]", json);
@@ -7346,7 +7348,7 @@ To fix this error either change the environment to be fully trusted, change the
string json = sw.ToString();
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""html"": ""\u003chtml\u003e\u003c/html\u003e""
}", json);
}
@@ -7556,7 +7558,7 @@ To fix this error either change the environment to be fully trusted, change the
}
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""<Active>k__BackingField"": false,
""<Ja>k__BackingField"": false,
""<Handlungsbedarf>k__BackingField"": false,
@@ -7575,7 +7577,7 @@ To fix this error either change the environment to be fully trusted, change the
string json = JsonConvert.SerializeObject(new[] { i }, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
123456789999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999990
]", json);
}
@@ -7634,7 +7636,7 @@ To fix this error either change the environment to be fully trusted, change the
Formatting = Formatting.Indented
});
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
{
""$id"": ""0b64ffdf-d155-44ad-9689-58d9adb137f3"",
""Name"": ""John Smith"",
@@ -7736,7 +7738,7 @@ To fix this error either change the environment to be fully trusted, change the
dict2.Add(consoleWriter, "Console");
var text2 = JsonConvert.SerializeObject(dict2, Formatting.Indented, options);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Console Writer"": ""Console""
}", text2);
@@ -7751,7 +7753,7 @@ To fix this error either change the environment to be fully trusted, change the
dict3.Add("Console", consoleWriter);
var text3 = JsonConvert.SerializeObject(dict3, Formatting.Indented, options);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Console"": ""Console Writer""
}", text3);
@@ -7888,7 +7890,7 @@ To fix this error either change the environment to be fully trusted, change the
{
var c = new TestClassConvertable { Id = new ConvertibleId { Value = 1 }, X = 2 };
var s = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Id"": ""1"",
""X"": 2
}", s);
@@ -8018,7 +8020,7 @@ To fix this error either change the environment to be fully trusted, change the
{ dt, "123" }
}, settings);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""2000-pie-Dec-Friday-22"": ""123""
}", json);
@@ -8044,7 +8046,7 @@ To fix this error either change the environment to be fully trusted, change the
{ dt, "123" }
}, settings);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""2000-pie-Dec-Friday-22"": ""123""
}", json);
@@ -8070,7 +8072,7 @@ To fix this error either change the environment to be fully trusted, change the
{ dt, "123" }
}, settings);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""2000-pie-Dec-Friday-22!+00:00"": ""123""
}", json);
@@ -8096,7 +8098,7 @@ To fix this error either change the environment to be fully trusted, change the
{ dt, "123" }
}, settings);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""2000-pie-Dec-Friday-22!+00:00"": ""123""
}", json);
@@ -151,7 +151,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string jsonString = JsonConvert.SerializeObject(expected, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""SourceTypeID"": ""d8220a4b-75b1-4b7a-8112-b7bdae956a45"",
""BrokerID"": ""951663c4-924e-4c86-a57a-7ed737501dbd"",
""Latitude"": 33.657145,
@@ -393,7 +393,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(typeNameProperty, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""Name!"",
""Value"": {
""$type"": """ + listRef + @""",
@@ -456,7 +456,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$id"": ""Id!"",
""$ref"": ""Ref!"",
""$value"": ""Value!"",
@@ -110,7 +110,7 @@ namespace Newtonsoft.Json.Tests.Serialization
// "Description": "It's no Bad Boys"
// }
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""Bad Boys III"",
""Description"": ""It's no Bad Boys"",
""Classification"": null,
@@ -119,7 +119,7 @@ namespace Newtonsoft.Json.Tests.Serialization
""ReleaseCountries"": null
}", included);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""Bad Boys III"",
""Description"": ""It's no Bad Boys""
}", ignored);
@@ -54,7 +54,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(circularDictionary, Formatting.Indented,
new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All });
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$id"": ""1"",
""other"": {
""$id"": ""2"",
@@ -120,7 +120,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting.Indented,
new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
null,
[
null
@@ -142,7 +142,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(circularList, Formatting.Indented,
new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All });
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$id"": ""1"",
""$values"": [
null,
@@ -271,7 +271,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(circularDictionary, Formatting.Indented,
new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""other"": {
""blah"": null
}
@@ -354,7 +354,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Converters = new List<JsonConverter> { new CircularReferenceClassConverter() }
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$id"": ""1"",
""$type"": ""CircularReferenceClass"",
""Name"": ""c1"",
@@ -428,7 +428,7 @@ namespace Newtonsoft.Json.Tests.Serialization
};
string json = JsonConvert.SerializeObject(employees, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
{
""$id"": ""1"",
""Name"": ""Mike Manager"",
@@ -486,7 +486,7 @@ namespace Newtonsoft.Json.Tests.Serialization
PreserveReferencesHandling = PreserveReferencesHandling.Objects
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$id"": ""1"",
""Name"": ""c1"",
""Child"": {
@@ -544,7 +544,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(employees, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
{
""$id"": ""1"",
""Name"": ""e1"",
@@ -614,7 +614,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(employees, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""One"": {
""$id"": ""1"",
""Name"": ""e1"",
@@ -841,7 +841,7 @@ namespace Newtonsoft.Json.Tests.Serialization
byte[] data = ms.ToArray();
string json = Encoding.UTF8.GetString(data, 0, data.Length);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$id"": ""1"",
""$values"": [
{
@@ -879,7 +879,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add(3);
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
1,
2,
3
@@ -897,7 +897,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add(c1);
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
{
""$id"": ""1"",
""MyProperty"": 0
@@ -921,7 +921,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add("Third", 3);
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""First"": 1,
""Second"": 2,
""Third"": 3
@@ -939,7 +939,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add("Third", c1);
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""First"": {
""$id"": ""1"",
""MyProperty"": 0
@@ -984,7 +984,7 @@ namespace Newtonsoft.Json.Tests.Serialization
""String"": ""String!"",
""Integer"": 2147483647
}";
Assert.AreEqual(expected, json);
StringAssert.AreEqual(expected, json);
ReferenceObject referenceObject = JsonConvert.DeserializeObject<ReferenceObject>(json);
Assert.IsNotNull(referenceObject);
@@ -1011,7 +1011,7 @@ namespace Newtonsoft.Json.Tests.Serialization
};
string json = JsonConvert.SerializeObject(o1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Data"": {
""Prop1"": {
""$id"": ""1"",
@@ -78,7 +78,7 @@ namespace Newtonsoft.Json.Tests.Serialization
{
ReferenceLoopHandling = ReferenceLoopHandling.Serialize
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Value"": {
""Value"": {
""Value"": {
@@ -128,7 +128,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Text"": ""Text!"",
""Data"": [
{
@@ -166,7 +166,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}
});
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
[
[
{
@@ -228,7 +228,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
{
""Member"": ""Value1"",
""ThrowError"": ""Handle this!"",
@@ -373,7 +373,7 @@ namespace Newtonsoft.Json.Tests.Serialization
// "Title": "Mister Manager"
//}
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""George Michael Bluth"",
""Age"": 16,
""Title"": ""Mister Manager""
@@ -68,7 +68,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(null, obj.Member5);
string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Member1"": 11,
""Member2"": ""This value went into the data file during serialization."",
""Member4"": null
@@ -115,7 +115,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(null, obj.Member4);
string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Member1"": 11,
""Member2"": ""This value went into the data file during serialization."",
""Member4"": null
@@ -151,7 +151,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(null, obj.Member4);
string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
-1.0,
1.1,
2.222222222,
@@ -189,7 +189,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(null, obj.Member4);
string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""1.1"": ""first"",
""2.222222222"": ""second"",
""2147483647"": ""third"",
@@ -277,7 +277,7 @@ namespace Newtonsoft.Json.Tests.Serialization
SerializationEventContextSubClassTestObject obj = new SerializationEventContextSubClassTestObject();
string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""TestMember"": ""Set!""
}", json);
}
@@ -307,7 +307,7 @@ namespace Newtonsoft.Json.Tests.Serialization
"ContextValue")
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""TestMember"": ""Remoting ContextValue""
}", json);
}
@@ -367,7 +367,7 @@ namespace Newtonsoft.Json.Tests.Serialization
IList<string> e = c.GetEvents();
Assert.AreEqual(@"OnDeserializing
StringAssert.AreEqual(@"OnDeserializing
OnDeserializing_Derived
OnDeserialized
OnDeserialized_Derived
@@ -386,7 +386,7 @@ OnSerialized_Derived", string.Join(Environment.NewLine, e.ToArray()));
IList<string> e = c.GetEvents();
Assert.AreEqual(@"OnDeserializing
StringAssert.AreEqual(@"OnDeserializing
OnDeserializing_Derived
OnDeserializing_Derived_Derived
OnDeserialized
@@ -415,7 +415,7 @@ OnSerialized_Derived_Derived", string.Join(Environment.NewLine, e.ToArray()));
IList<string> e = c.GetEvents();
Assert.AreEqual(@"OnDeserializing
StringAssert.AreEqual(@"OnDeserializing
OnDeserializing_Derived
OnDeserializing_Derived_Derived
OnDeserialized
@@ -145,14 +145,14 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Age"": 27
}", json);
c._shouldSerializeName = true;
json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""James"",
""Age"": 27
}", json);
@@ -199,7 +199,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Age"": 27
}", json);
@@ -217,7 +217,7 @@ namespace Newtonsoft.Json.Tests.Serialization
c.FavoriteNumber = 23;
json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""James"",
""Age"": 27,
""Weight"": 0,
@@ -356,7 +356,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(joe, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Age"": 100,
""Name"": ""Joe Employee"",
""Manager"": {
@@ -58,7 +58,7 @@ namespace Newtonsoft.Json.Tests.Serialization
traceWriter.Trace(TraceLevel.Error, "Error!", null);
traceWriter.Trace(TraceLevel.Off, "Off!", null);
Assert.AreEqual(@"Newtonsoft.Json Verbose: 0 : Verbose!
StringAssert.AreEqual(@"Newtonsoft.Json Verbose: 0 : Verbose!
Newtonsoft.Json Information: 0 : Info!
Newtonsoft.Json Warning: 0 : Warning!
Newtonsoft.Json Error: 0 : Error!
@@ -111,6 +111,9 @@ Newtonsoft.Json Error: 0 : Error!
]
}";
json = StringAssert.Normalize(json);
output = StringAssert.Normalize(output);
Assert.IsTrue(output.Contains(json));
}
@@ -167,6 +170,9 @@ Newtonsoft.Json Error: 0 : Error!
Assert.AreEqual(1059, output.Length);
Assert.AreEqual(7, memoryTraceWriter.GetTraceMessages().Count());
json = StringAssert.Normalize(json);
output = StringAssert.Normalize(output);
Assert.IsTrue(output.Contains(json));
}
@@ -745,7 +751,7 @@ Newtonsoft.Json Error: 0 : Error!
Assert.AreEqual("IsSpecified result for property 'FavoriteNumber' on Newtonsoft.Json.Tests.Serialization.SpecifiedTestClass: False. Path 'Age'.", traceWriter.TraceRecords[4].Message);
Assert.AreEqual("Finished serializing Newtonsoft.Json.Tests.Serialization.SpecifiedTestClass. Path ''.", traceWriter.TraceRecords[5].Message);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Age"": 27
}", json);
@@ -772,7 +778,7 @@ Newtonsoft.Json Error: 0 : Error!
c.FavoriteNumber = 23;
json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""James"",
""Age"": 27,
""Weight"": 0,
@@ -870,7 +876,7 @@ Newtonsoft.Json Error: 0 : Error!
Console.WriteLine(traceWriter.GetJson());
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Array"": [
""String!"",
""2000-12-12T12:12:12Z"",
@@ -1031,7 +1037,7 @@ Newtonsoft.Json Error: 0 : Error!
Console.WriteLine(traceReader.GetJson());
Assert.AreEqual(json, traceReader.GetJson());
StringAssert.AreEqual(json, traceReader.GetJson());
}
#endif
}
@@ -67,7 +67,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameHandling = TypeNameHandling.Auto
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""movie"": {
""$type"": ""Newtonsoft.Json.Tests.TestObjects.Movie, Newtonsoft.Json.Tests"",
""Name"": ""Die Hard"",
@@ -93,7 +93,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameHandling = TypeNameHandling.Auto
});
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
{
""Key"": ""movie"",
""Value"": {
@@ -138,7 +138,7 @@ namespace Newtonsoft.Json.Tests.Serialization
serializer.Serialize(new JsonTextWriter(sw) { Formatting = Formatting.Indented }, new WagePerson(), typeof(Person));
var result = sw.ToString();
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$type"": ""Newtonsoft.Json.Tests.TestObjects.WagePerson, Newtonsoft.Json.Tests"",
""HourlyWage"": 0.0,
""Name"": null,
@@ -163,7 +163,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameHandling = TypeNameHandling.Auto
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$type"": ""Newtonsoft.Json.Tests.TestObjects.WagePerson, Newtonsoft.Json.Tests"",
""HourlyWage"": 0.0,
""Name"": null,
@@ -196,7 +196,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameHandling = TypeNameHandling.Auto
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Array"": [
{
""$id"": ""1"",
@@ -230,7 +230,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameHandling = TypeNameHandling.Objects
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$id"": ""1"",
""$type"": """ + employeeRef + @""",
""Name"": null,
@@ -308,7 +308,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameAssemblyFormat = FormatterAssemblyStyle.Full
});
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
{
""$id"": ""1"",
""$type"": """ + employeeRef + @""",
@@ -422,7 +422,7 @@ namespace Newtonsoft.Json.Tests.Serialization
JObject o = (JObject)JsonConvert.DeserializeObject(json);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""Name!"",
""Manager"": null
}", o.ToString());
@@ -523,7 +523,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameAssemblyFormat = FormatterAssemblyStyle.Full
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$type"": """ + containerTypeName + @""",
""In"": {
""$type"": """ + productListTypeName + @""",
@@ -560,7 +560,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(typeNameProperty, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""Name!"",
""Value"": {
""$type"": """ + typeNamePropertyRef + @""",
@@ -591,7 +591,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(typeNameProperty, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Name"": ""Name!"",
""Value"": {
""$type"": """ + listRef + @""",
@@ -688,7 +688,7 @@ namespace Newtonsoft.Json.Tests.Serialization
//]
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
{
""$type"": ""Customer"",
""Name"": ""Caroline Customer""
@@ -787,7 +787,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}
}";
Assert.AreEqual(expected, json);
StringAssert.AreEqual(expected, json);
StringReader sr = new StringReader(json);
@@ -872,7 +872,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string urlStatusTypeName = ReflectionUtils.GetTypeName(typeof(UrlStatus), FormatterAssemblyStyle.Simple, null);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$type"": ""System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib"",
""First"": {
""$type"": """ + urlStatusTypeName + @""",
@@ -927,7 +927,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(products, Formatting.Indented, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All });
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$type"": """ + productClassRef + @""",
""$values"": []
}", json);
@@ -1007,7 +1007,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string carClassRef = ReflectionUtils.GetTypeName(typeof(Car), FormatterAssemblyStyle.Simple, null);
Assert.AreEqual(output, @"{
StringAssert.AreEqual(output, @"{
""$type"": """ + carClassRef + @""",
""Year"": ""2000-10-05T01:01:01Z"",
""Objects"": {
@@ -1103,7 +1103,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}
});
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""$type"": "":::MESSAGE:::, AssemblyName"",
""Address"": ""jamesnk@testtown.com"",
""Body"": {
@@ -1146,7 +1146,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add(3);
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
1,
2,
3
@@ -1169,7 +1169,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add(long.MaxValue);
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[
StringAssert.AreEqual(@"[
{
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
""MyProperty"": 0
@@ -1204,7 +1204,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add("Third", long.MaxValue);
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""First"": {
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
""MyProperty"": 1
@@ -1246,7 +1246,7 @@ namespace Newtonsoft.Json.Tests.Serialization
""String"": ""String!"",
""Integer"": 2147483647
}";
Assert.AreEqual(expected, json);
StringAssert.AreEqual(expected, json);
TypeNameObject o2 = JsonConvert.DeserializeObject<TypeNameObject>(json);
Assert.IsNotNull(o2);
@@ -1255,7 +1255,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(1, ((TestComponentSimple)o2.Object1).MyProperty);
CustomAssert.IsInstanceOfType(typeof(long), o2.Object2);
CustomAssert.IsInstanceOfType(typeof(JObject), o2.ObjectNotHandled);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""MyProperty"": 2147483647
}", o2.ObjectNotHandled.ToString());
}
@@ -1272,7 +1272,7 @@ namespace Newtonsoft.Json.Tests.Serialization
};
string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Data"": [
1,
""two"",
@@ -1312,7 +1312,7 @@ namespace Newtonsoft.Json.Tests.Serialization
};
string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Data"": [
{
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
@@ -1391,7 +1391,7 @@ namespace Newtonsoft.Json.Tests.Serialization
};
string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Data"": {
""one"": {
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
@@ -1466,7 +1466,7 @@ namespace Newtonsoft.Json.Tests.Serialization
};
string json = JsonConvert.SerializeObject(o1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Data"": {
""Prop1"": {
""$type"": ""System.Collections.Generic.List`1[[System.Object, mscorlib]], mscorlib"",
@@ -1522,7 +1522,7 @@ namespace Newtonsoft.Json.Tests.Serialization
d1.Data = (DynamicDictionary)data;
string json = JsonConvert.SerializeObject(d1, Formatting.Indented);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""Data"": {
""one"": {
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
@@ -1620,7 +1620,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(p, settings);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""c"": {
""$type"": ""Newtonsoft.Json.Tests.Serialization.MyChild, Newtonsoft.Json.Tests"",
""p"": ""string!""
@@ -1655,7 +1655,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(p, settings);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""c"": {
""$type"": ""Newtonsoft.Json.Tests.Serialization.MyChildList, Newtonsoft.Json.Tests"",
""$values"": [
@@ -1694,7 +1694,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(pp, settings);
Assert.AreEqual(@"{
StringAssert.AreEqual(@"{
""ParentProp"": {
""c"": {
""$type"": ""Newtonsoft.Json.Tests.Serialization.MyChild, Newtonsoft.Json.Tests"",