-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
@@ -98,7 +98,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(binaryClass, Formatting.Indented, new BinaryConverter()); string json = JsonConvert.SerializeObject(binaryClass, Formatting.Indented, new BinaryConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Binary"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="", ""Binary"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="",
""NullBinary"": null ""NullBinary"": null
}", json); }", json);
@@ -114,7 +114,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(byteArrayClass, Formatting.Indented); string json = JsonConvert.SerializeObject(byteArrayClass, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""ByteArray"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="", ""ByteArray"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="",
""NullByteArray"": null ""NullByteArray"": null
}", json); }", json);
@@ -138,7 +138,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(sqlBinaryClass, Formatting.Indented, new BinaryConverter()); string json = JsonConvert.SerializeObject(sqlBinaryClass, Formatting.Indented, new BinaryConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""SqlBinary"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="", ""SqlBinary"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="",
""NullableSqlBinary1"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="", ""NullableSqlBinary1"": ""VGhpcyBpcyBzb21lIHRlc3QgZGF0YSEhIQ=="",
""NullableSqlBinary2"": null ""NullableSqlBinary2"": null
@@ -230,7 +230,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(initial, Formatting.Indented); string json = JsonConvert.SerializeObject(initial, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Id"": ""00000001-0002-0003-0405-060708090a0b"", ""Id"": ""00000001-0002-0003-0405-060708090a0b"",
""Year"": 2010, ""Year"": 2010,
""Company"": ""Company!"", ""Company"": ""Company!"",
@@ -72,7 +72,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(dataSet, Formatting.Indented); string json = JsonConvert.SerializeObject(dataSet, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Table1"": [ ""Table1"": [
{ {
""id"": 0, ""id"": 0,
@@ -143,7 +143,7 @@ namespace Newtonsoft.Json.Tests.Converters
DataSet deserializedDs = JsonConvert.DeserializeObject<DataSet>(json, new IsoDateTimeConverter()); DataSet deserializedDs = JsonConvert.DeserializeObject<DataSet>(json, new IsoDateTimeConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""FirstTable"": [ ""FirstTable"": [
{ {
""StringCol"": ""Item Name"", ""StringCol"": ""Item Name"",
@@ -296,7 +296,7 @@ namespace Newtonsoft.Json.Tests.Converters
ContractResolver = new CamelCasePropertyNamesContractResolver() ContractResolver = new CamelCasePropertyNamesContractResolver()
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""firstTable"": [ ""firstTable"": [
{ {
""stringCol"": ""Item Name"", ""stringCol"": ""Item Name"",
@@ -346,7 +346,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(c, Formatting.Indented, new IsoDateTimeConverter()); string json = JsonConvert.SerializeObject(c, Formatting.Indented, new IsoDateTimeConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Before"": ""Before"", ""Before"": ""Before"",
""Set"": { ""Set"": {
""FirstTable"": [ ""FirstTable"": [
@@ -417,7 +417,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(ds, Formatting.Indented); string json = JsonConvert.SerializeObject(ds, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Customers"": [ ""Customers"": [
{ {
""CustomerID"": ""234"" ""CustomerID"": ""234""
@@ -434,7 +434,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json1 = JsonConvert.SerializeObject(ds1, Formatting.Indented); string json1 = JsonConvert.SerializeObject(ds1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Customers"": [ ""Customers"": [
{ {
""CustomerID"": ""234"" ""CustomerID"": ""234""
@@ -220,7 +220,7 @@ namespace Newtonsoft.Json.Tests.Converters
myTable.Rows.Add(myNewRow); myTable.Rows.Add(myNewRow);
string json = JsonConvert.SerializeObject(myTable, Formatting.Indented); string json = JsonConvert.SerializeObject(myTable, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""StringCol"": ""Item Name"", ""StringCol"": ""Item Name"",
""Int32Col"": 2147483647, ""Int32Col"": 2147483647,
@@ -293,7 +293,7 @@ namespace Newtonsoft.Json.Tests.Converters
serializer.Serialize(bw, table); serializer.Serialize(bw, table);
JToken o = JToken.ReadFrom(new BsonReader(new MemoryStream(ms.ToArray())) { ReadRootValueAsArray = true }); JToken o = JToken.ReadFrom(new BsonReader(new MemoryStream(ms.ToArray())) { ReadRootValueAsArray = true });
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""data"": ""SGVsbG8gd29ybGQh"", ""data"": ""SGVsbG8gd29ybGQh"",
""id"": ""ede9a599-a7d9-44a9-9243-7c287049dd20"" ""id"": ""ede9a599-a7d9-44a9-9243-7c287049dd20""
@@ -404,7 +404,7 @@ namespace Newtonsoft.Json.Tests.Converters
KeyValuePair<DataTable, int> pair = new KeyValuePair<DataTable, int>(table, 1); KeyValuePair<DataTable, int> pair = new KeyValuePair<DataTable, int>(table, 1);
string serializedpair = JsonConvert.SerializeObject(pair, Formatting.Indented); string serializedpair = JsonConvert.SerializeObject(pair, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Key"": [ ""Key"": [
{ {
""id"": 0, ""id"": 0,
@@ -430,7 +430,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(dt, Formatting.Indented); string json = JsonConvert.SerializeObject(dt, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""CustomerID"": ""432"" ""CustomerID"": ""432""
} }
@@ -81,7 +81,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(d, Formatting.Indented); string json = JsonConvert.SerializeObject(d, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Before"": ""Before!"", ""Before"": ""Before!"",
""Expando"": { ""Expando"": {
""String"": ""String!"", ""String"": ""String!"",
@@ -107,7 +107,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(d, Formatting.Indented); string json = JsonConvert.SerializeObject(d, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Before"": null, ""Before"": null,
""Expando"": null, ""Expando"": null,
""After"": null ""After"": null
@@ -139,7 +139,7 @@ namespace Newtonsoft.Json.Tests.Converters
l1.Add(new DateTime(1983, 10, 9, 23, 10, 0, DateTimeKind.Utc)); l1.Add(new DateTime(1983, 10, 9, 23, 10, 0, DateTimeKind.Utc));
string json = JsonConvert.SerializeObject(l1, Formatting.Indented); string json = JsonConvert.SerializeObject(l1, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
new Date( new Date(
976651800000 976651800000
), ),
@@ -163,7 +163,7 @@ namespace Newtonsoft.Json.Tests.Converters
l1.Add("Second", new DateTime(1983, 10, 9, 23, 10, 0, DateTimeKind.Utc)); l1.Add("Second", new DateTime(1983, 10, 9, 23, 10, 0, DateTimeKind.Utc));
string json = JsonConvert.SerializeObject(l1, Formatting.Indented); string json = JsonConvert.SerializeObject(l1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""First"": new Date( ""First"": new Date(
976651800000 976651800000
), ),
@@ -188,7 +188,7 @@ namespace Newtonsoft.Json.Tests.Converters
l1.ObjectNotHandled = new DateTime(2000, 12, 12, 20, 10, 0, DateTimeKind.Utc); l1.ObjectNotHandled = new DateTime(2000, 12, 12, 20, 10, 0, DateTimeKind.Utc);
string json = JsonConvert.SerializeObject(l1, Formatting.Indented); string json = JsonConvert.SerializeObject(l1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Object1"": new Date( ""Object1"": new Date(
976651800000 976651800000
), ),
@@ -32,7 +32,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(values, Formatting.Indented); string json = JsonConvert.SerializeObject(values, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""Key"": ""123"", ""Key"": ""123"",
""Value"": 123 ""Value"": 123
@@ -63,7 +63,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(regex, Formatting.Indented, new RegexConverter()); string json = JsonConvert.SerializeObject(regex, Formatting.Indented, new RegexConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Pattern"": ""abc"", ""Pattern"": ""abc"",
""Options"": 513 ""Options"": 513
}", json); }", json);
@@ -80,7 +80,7 @@ namespace Newtonsoft.Json.Tests.Converters
ContractResolver = new CamelCasePropertyNamesContractResolver() ContractResolver = new CamelCasePropertyNamesContractResolver()
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""pattern"": ""abc"", ""pattern"": ""abc"",
""options"": ""ignoreCase"" ""options"": ""ignoreCase""
}", json); }", json);
@@ -223,7 +223,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(new RegexTestClass { Regex = regex }, Formatting.Indented, new RegexConverter()); string json = JsonConvert.SerializeObject(new RegexTestClass { Regex = regex }, Formatting.Indented, new RegexConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Regex"": { ""Regex"": {
""Pattern"": """", ""Pattern"": """",
""Options"": 0 ""Options"": 0
@@ -124,7 +124,7 @@ namespace Newtonsoft.Json.Tests.Converters
}; };
string json = JsonConvert.SerializeObject(c, Formatting.Indented, new StringEnumConverter()); string json = JsonConvert.SerializeObject(c, Formatting.Indented, new StringEnumConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Enum"": ""@first"" ""Enum"": ""@first""
}", json); }", json);
@@ -134,7 +134,7 @@ namespace Newtonsoft.Json.Tests.Converters
}; };
json = JsonConvert.SerializeObject(c, Formatting.Indented, new StringEnumConverter()); json = JsonConvert.SerializeObject(c, Formatting.Indented, new StringEnumConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Enum"": ""Third"" ""Enum"": ""Third""
}", json); }", json);
} }
@@ -168,7 +168,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter()); string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""StoreColor"": ""Red"", ""StoreColor"": ""Red"",
""NullableStoreColor1"": ""White"", ""NullableStoreColor1"": ""White"",
""NullableStoreColor2"": null ""NullableStoreColor2"": null
@@ -185,7 +185,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter { CamelCaseText = true }); string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter { CamelCaseText = true });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""StoreColor"": ""red"", ""StoreColor"": ""red"",
""NullableStoreColor1"": ""darkGoldenrod"", ""NullableStoreColor1"": ""darkGoldenrod"",
""NullableStoreColor2"": null ""NullableStoreColor2"": null
@@ -202,7 +202,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter()); string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""StoreColor"": 1000, ""StoreColor"": 1000,
""NullableStoreColor1"": 1000, ""NullableStoreColor1"": 1000,
""NullableStoreColor2"": null ""NullableStoreColor2"": null
@@ -219,7 +219,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter()); string json = JsonConvert.SerializeObject(enumClass, Formatting.Indented, new StringEnumConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""StoreColor"": ""Red, White"", ""StoreColor"": ""Red, White"",
""NullableStoreColor1"": 0, ""NullableStoreColor1"": 0,
""NullableStoreColor2"": ""Black, Red, White"" ""NullableStoreColor2"": ""Black, Red, White""
@@ -235,7 +235,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(negativeEnumClass, Formatting.Indented, new StringEnumConverter()); string json = JsonConvert.SerializeObject(negativeEnumClass, Formatting.Indented, new StringEnumConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Value1"": ""Negative"", ""Value1"": ""Negative"",
""Value2"": -2147483648 ""Value2"": -2147483648
}", json); }", json);
@@ -312,7 +312,7 @@ namespace Newtonsoft.Json.Tests.Converters
}; };
string json = JsonConvert.SerializeObject(c, Formatting.Indented, new StringEnumConverter { CamelCaseText = true }); string json = JsonConvert.SerializeObject(c, Formatting.Indented, new StringEnumConverter { CamelCaseText = true });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Enum"": ""first, second"" ""Enum"": ""first, second""
}", json); }", json);
} }
@@ -404,7 +404,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json1 = JsonConvert.SerializeObject(lfoo, Formatting.Indented, new StringEnumConverter { CamelCaseText = true }); string json1 = JsonConvert.SerializeObject(lfoo, Formatting.Indented, new StringEnumConverter { CamelCaseText = true });
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""Bat, baz"", ""Bat, baz"",
""foo_bar"", ""foo_bar"",
""Bat"", ""Bat"",
@@ -427,7 +427,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json2 = JsonConvert.SerializeObject(lbar, Formatting.Indented, new StringEnumConverter { CamelCaseText = true }); string json2 = JsonConvert.SerializeObject(lbar, Formatting.Indented, new StringEnumConverter { CamelCaseText = true });
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""foo_bar"", ""foo_bar"",
""Bat"", ""Bat"",
""baz"" ""baz""
@@ -72,7 +72,7 @@ namespace Newtonsoft.Json.Tests.Converters
""StringProperty2"": ""StringProperty2"" ""StringProperty2"": ""StringProperty2""
}}", version1, version2); }}", version1, version2);
Assert.AreEqual(expectedJson, json); StringAssert.AreEqual(expectedJson, json);
} }
[Test] [Test]
@@ -195,7 +195,7 @@ namespace Newtonsoft.Json.Tests.Converters
var json = JsonConvert.SerializeObject(result, Formatting.Indented); // <--- fails here with the cast message var json = JsonConvert.SerializeObject(result, Formatting.Indented); // <--- fails here with the cast message
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""Country"": ""6"" ""Country"": ""6""
}, },
@@ -232,7 +232,7 @@ namespace Newtonsoft.Json.Tests.Converters
var json = JsonConvert.SerializeObject(result, Formatting.Indented); // <--- fails here with the cast message var json = JsonConvert.SerializeObject(result, Formatting.Indented); // <--- fails here with the cast message
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""Country"": ""6"" ""Country"": ""6""
}, },
@@ -320,7 +320,7 @@ namespace Newtonsoft.Json.Tests.Converters
XDocument doc = JsonConvert.DeserializeXNode(json); XDocument doc = JsonConvert.DeserializeXNode(json);
Assert.AreEqual(@"<root> StringAssert.AreEqual(@"<root>
<p>Text1 Text2<span>Span1</span><span>Span2</span></p> <p>Text1 Text2<span>Span1</span><span>Span2</span></p>
</root>", doc.ToString()); </root>", doc.ToString());
} }
@@ -425,7 +425,7 @@ namespace Newtonsoft.Json.Tests.Converters
} }
}"; }";
Assert.AreEqual(expected, jsonText); StringAssert.AreEqual(expected, jsonText);
Console.WriteLine("DocumentSerializeIndented"); Console.WriteLine("DocumentSerializeIndented");
Console.WriteLine(jsonText); Console.WriteLine(jsonText);
@@ -507,7 +507,7 @@ namespace Newtonsoft.Json.Tests.Converters
jsonText = JsonConvert.SerializeXmlNode(element, Formatting.Indented); jsonText = JsonConvert.SerializeXmlNode(element, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""xs:Choice"": { ""xs:Choice"": {
""@msdata:IsDataSet"": """", ""@msdata:IsDataSet"": """",
""@xmlns:xs"": ""http://www.w3.org/2001/XMLSchema"", ""@xmlns:xs"": ""http://www.w3.org/2001/XMLSchema"",
@@ -620,22 +620,22 @@ namespace Newtonsoft.Json.Tests.Converters
string json1 = JsonConvert.SerializeXmlNode(doc1, Formatting.Indented); string json1 = JsonConvert.SerializeXmlNode(doc1, Formatting.Indented);
Assert.AreEqual(expected, json1); StringAssert.AreEqual(expected, json1);
XmlDocument doc11 = JsonConvert.DeserializeXmlNode(json1); XmlDocument doc11 = JsonConvert.DeserializeXmlNode(json1);
Assert.AreEqual(xml, ToStringWithDeclaration(doc11)); StringAssert.AreEqual(xml, ToStringWithDeclaration(doc11));
#if !NET20 #if !NET20
XDocument doc2 = XDocument.Parse(xml); XDocument doc2 = XDocument.Parse(xml);
string json2 = JsonConvert.SerializeXNode(doc2, Formatting.Indented); string json2 = JsonConvert.SerializeXNode(doc2, Formatting.Indented);
Assert.AreEqual(expected, json2); StringAssert.AreEqual(expected, json2);
XDocument doc22 = JsonConvert.DeserializeXNode(json2); XDocument doc22 = JsonConvert.DeserializeXNode(json2);
Assert.AreEqual(xml, ToStringWithDeclaration(doc22)); StringAssert.AreEqual(xml, ToStringWithDeclaration(doc22));
#endif #endif
} }
@@ -747,7 +747,7 @@ namespace Newtonsoft.Json.Tests.Converters
} }
}"; }";
Assert.AreEqual(expected, jsonText); StringAssert.AreEqual(expected, jsonText);
XmlDocument deserializedDoc = (XmlDocument)DeserializeXmlNode(jsonText); XmlDocument deserializedDoc = (XmlDocument)DeserializeXmlNode(jsonText);
@@ -796,7 +796,7 @@ namespace Newtonsoft.Json.Tests.Converters
Console.WriteLine(formattedXml); Console.WriteLine(formattedXml);
Console.WriteLine(); Console.WriteLine();
Assert.AreEqual(expected, formattedXml); StringAssert.AreEqual(expected, formattedXml);
} }
private string GetIndentedInnerXml(XmlNode node) private string GetIndentedInnerXml(XmlNode node)
@@ -913,7 +913,7 @@ namespace Newtonsoft.Json.Tests.Converters
} }
}"; }";
Assert.AreEqual(expected, json); StringAssert.AreEqual(expected, json);
} }
[Test] [Test]
@@ -943,7 +943,7 @@ namespace Newtonsoft.Json.Tests.Converters
} }
} }
}"; }";
Assert.AreEqual(expected, arrayJsonText); StringAssert.AreEqual(expected, arrayJsonText);
arrayXml = @"<root xmlns:json=""http://james.newtonking.com/projects/json""> arrayXml = @"<root xmlns:json=""http://james.newtonking.com/projects/json"">
<person id=""1""> <person id=""1"">
@@ -971,7 +971,7 @@ namespace Newtonsoft.Json.Tests.Converters
} }
} }
}"; }";
Assert.AreEqual(expected, arrayJsonText); StringAssert.AreEqual(expected, arrayJsonText);
arrayXml = @"<root xmlns:json=""http://james.newtonking.com/projects/json""> arrayXml = @"<root xmlns:json=""http://james.newtonking.com/projects/json"">
<person id=""1""> <person id=""1"">
@@ -995,7 +995,7 @@ namespace Newtonsoft.Json.Tests.Converters
} }
} }
}"; }";
Assert.AreEqual(expected, arrayJsonText); StringAssert.AreEqual(expected, arrayJsonText);
} }
[Test] [Test]
@@ -1055,7 +1055,7 @@ namespace Newtonsoft.Json.Tests.Converters
string xml = IndentXml(newDoc.InnerXml); string xml = IndentXml(newDoc.InnerXml);
Assert.AreEqual(@"<myRoot> StringAssert.AreEqual(@"<myRoot>
<available_sizes> <available_sizes>
<available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes> <available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes>
<available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes> <available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes>
@@ -1072,7 +1072,7 @@ namespace Newtonsoft.Json.Tests.Converters
#if !NET20 #if !NET20
XDocument newXDoc = JsonConvert.DeserializeXNode(json, "myRoot"); XDocument newXDoc = JsonConvert.DeserializeXNode(json, "myRoot");
Assert.AreEqual(@"<myRoot> StringAssert.AreEqual(@"<myRoot>
<available_sizes> <available_sizes>
<available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes> <available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes>
<available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes> <available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes>
@@ -1112,7 +1112,7 @@ namespace Newtonsoft.Json.Tests.Converters
XmlDocument newDoc = JsonConvert.DeserializeXmlNode(json, "myRoot", true); XmlDocument newDoc = JsonConvert.DeserializeXmlNode(json, "myRoot", true);
Assert.AreEqual(@"<myRoot> StringAssert.AreEqual(@"<myRoot>
<available_sizes json:Array=""true"" xmlns:json=""http://james.newtonking.com/projects/json""> <available_sizes json:Array=""true"" xmlns:json=""http://james.newtonking.com/projects/json"">
<available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes> <available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes>
<available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes> <available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes>
@@ -1131,7 +1131,7 @@ namespace Newtonsoft.Json.Tests.Converters
Console.WriteLine(IndentXml(newXDoc.ToString(SaveOptions.DisableFormatting))); Console.WriteLine(IndentXml(newXDoc.ToString(SaveOptions.DisableFormatting)));
Assert.AreEqual(@"<myRoot> StringAssert.AreEqual(@"<myRoot>
<available_sizes json:Array=""true"" xmlns:json=""http://james.newtonking.com/projects/json""> <available_sizes json:Array=""true"" xmlns:json=""http://james.newtonking.com/projects/json"">
<available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes> <available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes>
<available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes> <available_sizes>assets/images/resized/0001/1070/11070v1-max-150x150.jpg</available_sizes>
@@ -1147,7 +1147,7 @@ namespace Newtonsoft.Json.Tests.Converters
#endif #endif
string newJson = JsonConvert.SerializeXmlNode(newDoc, Formatting.Indented, true); string newJson = JsonConvert.SerializeXmlNode(newDoc, Formatting.Indented, true);
Assert.AreEqual(json, newJson); StringAssert.AreEqual(json, newJson);
} }
[Test] [Test]
@@ -1189,7 +1189,7 @@ namespace Newtonsoft.Json.Tests.Converters
doc.LoadXml(@"<name>O""Connor</name>"); // i use "" so it will be easier to see the problem doc.LoadXml(@"<name>O""Connor</name>"); // i use "" so it will be easier to see the problem
string json = SerializeXmlNode(doc); string json = SerializeXmlNode(doc);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""name"": ""O\""Connor"" ""name"": ""O\""Connor""
}", json); }", json);
} }
@@ -1216,7 +1216,7 @@ namespace Newtonsoft.Json.Tests.Converters
} }
}"; }";
Assert.AreEqual(expected, jsonText); StringAssert.AreEqual(expected, jsonText);
XmlDocument newDoc = (XmlDocument)DeserializeXmlNode(jsonText); XmlDocument newDoc = (XmlDocument)DeserializeXmlNode(jsonText);
Assert.AreEqual(@"<span class=""vevent""><a class=""url"" href=""http://www.web2con.com/"">Text</a><!-- Hi! --></span>", newDoc.InnerXml); Assert.AreEqual(@"<span class=""vevent""><a class=""url"" href=""http://www.web2con.com/"">Text</a><!-- Hi! --></span>", newDoc.InnerXml);
@@ -1265,7 +1265,7 @@ namespace Newtonsoft.Json.Tests.Converters
// format // format
jsonText = JObject.Parse(jsonText).ToString(); jsonText = JObject.Parse(jsonText).ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""?xml"": { ""?xml"": {
""@version"": ""1.0"", ""@version"": ""1.0"",
""@standalone"": ""no"" ""@standalone"": ""no""
@@ -1328,17 +1328,7 @@ namespace Newtonsoft.Json.Tests.Converters
// </person> // </person>
// </root> // </root>
Assert.AreEqual(@"<?xml version=""1.0"" standalone=""no""?> StringAssert.AreEqual(@"<?xml version=""1.0"" standalone=""no""?><root><person id=""1""><name>Alan</name><url>http://www.google.com</url></person><person id=""2""><name>Louis</name><url>http://www.yahoo.com</url></person></root>", doc.InnerXml);
<root>
<person id=""1"">
<name>Alan</name>
<url>http://www.google.com</url>
</person>
<person id=""2"">
<name>Louis</name>
<url>http://www.yahoo.com</url>
</person>
</root>".Replace(Environment.NewLine, string.Empty), doc.InnerXml);
} }
[Test] [Test]
@@ -1351,7 +1341,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeObject(circularDictionary, Formatting.Indented, string json = JsonConvert.SerializeObject(circularDictionary, Formatting.Indented,
new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All }); new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$id"": ""1"", ""$id"": ""1"",
""other"": { ""other"": {
""$id"": ""2"", ""$id"": ""2"",
@@ -1372,7 +1362,7 @@ namespace Newtonsoft.Json.Tests.Converters
<self json:ref=""1"" /> <self json:ref=""1"" />
</root>"; </root>";
Assert.AreEqual(expected, xml); StringAssert.AreEqual(expected, xml);
string xmlJson = SerializeXmlNode(node); string xmlJson = SerializeXmlNode(node);
string expectedXmlJson = @"{ string expectedXmlJson = @"{
@@ -1388,7 +1378,7 @@ namespace Newtonsoft.Json.Tests.Converters
} }
}"; }";
Assert.AreEqual(expectedXmlJson, xmlJson); StringAssert.AreEqual(expectedXmlJson, xmlJson);
} }
[Test] [Test]
@@ -1490,7 +1480,7 @@ namespace Newtonsoft.Json.Tests.Converters
XmlDocument xmlProduct = JsonConvert.DeserializeXmlNode(output, "product", true); XmlDocument xmlProduct = JsonConvert.DeserializeXmlNode(output, "product", true);
Assert.AreEqual(@"<product> StringAssert.AreEqual(@"<product>
<Name>Apple</Name> <Name>Apple</Name>
<ExpiryDate>2008-12-28T00:00:00Z</ExpiryDate> <ExpiryDate>2008-12-28T00:00:00Z</ExpiryDate>
<Price>3.99</Price> <Price>3.99</Price>
@@ -1499,7 +1489,7 @@ namespace Newtonsoft.Json.Tests.Converters
string output2 = JsonConvert.SerializeXmlNode(xmlProduct.DocumentElement, Formatting.Indented); string output2 = JsonConvert.SerializeXmlNode(xmlProduct.DocumentElement, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""product"": { ""product"": {
""Name"": ""Apple"", ""Name"": ""Apple"",
""ExpiryDate"": ""2008-12-28T00:00:00Z"", ""ExpiryDate"": ""2008-12-28T00:00:00Z"",
@@ -1533,7 +1523,7 @@ namespace Newtonsoft.Json.Tests.Converters
XmlDocument xmlProduct = JsonConvert.DeserializeXmlNode(output, "test", true); XmlDocument xmlProduct = JsonConvert.DeserializeXmlNode(output, "test", true);
Assert.AreEqual(@"<test> StringAssert.AreEqual(@"<test>
<Name>Hi</Name> <Name>Hi</Name>
<Products json:Array=""true"" xmlns:json=""http://james.newtonking.com/projects/json""> <Products json:Array=""true"" xmlns:json=""http://james.newtonking.com/projects/json"">
<Name>First</Name> <Name>First</Name>
@@ -1545,7 +1535,7 @@ namespace Newtonsoft.Json.Tests.Converters
string output2 = JsonConvert.SerializeXmlNode(xmlProduct.DocumentElement, Formatting.Indented, true); string output2 = JsonConvert.SerializeXmlNode(xmlProduct.DocumentElement, Formatting.Indented, true);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""Hi"", ""Name"": ""Hi"",
""Products"": [ ""Products"": [
{ {
@@ -1594,7 +1584,7 @@ namespace Newtonsoft.Json.Tests.Converters
string output = JsonConvert.SerializeXmlNode(d, Formatting.Indented, true); string output = JsonConvert.SerializeXmlNode(d, Formatting.Indented, true);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": [ ""Name"": [
""Hi"", ""Hi"",
""Hi"" ""Hi""
@@ -1627,7 +1617,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeXmlNode(d, Formatting.Indented); string json = JsonConvert.SerializeXmlNode(d, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""?xml"": { ""?xml"": {
""@version"": ""1.0"", ""@version"": ""1.0"",
""@encoding"": ""utf-8"" ""@encoding"": ""utf-8""
@@ -1649,7 +1639,7 @@ namespace Newtonsoft.Json.Tests.Converters
XmlDocument d2 = JsonConvert.DeserializeXmlNode(json); XmlDocument d2 = JsonConvert.DeserializeXmlNode(json);
Assert.AreEqual(@"<?xml version=""1.0"" encoding=""utf-8""?> StringAssert.AreEqual(@"<?xml version=""1.0"" encoding=""utf-8""?>
<root> <root>
<A> <A>
<B name=""sample"" /> <B name=""sample"" />
@@ -1671,7 +1661,7 @@ namespace Newtonsoft.Json.Tests.Converters
string json = JsonConvert.SerializeXmlNode(d, Formatting.Indented); string json = JsonConvert.SerializeXmlNode(d, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""root"": { ""root"": {
""Reports"": [ ""Reports"": [
{} {}
@@ -1920,7 +1910,7 @@ namespace Newtonsoft.Json.Tests.Converters
} }
}"; }";
Assert.AreEqual(expectedJson, json); StringAssert.AreEqual(expectedJson, json);
XNode node = JsonConvert.DeserializeXNode(json); XNode node = JsonConvert.DeserializeXNode(json);
@@ -1959,7 +1949,7 @@ namespace Newtonsoft.Json.Tests.Converters
<TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" /> <TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
</Grid>"; </Grid>";
Assert.AreEqual(expectedXaml, xaml2); StringAssert.AreEqual(expectedXaml, xaml2);
} }
#endif #endif
@@ -2161,7 +2151,7 @@ namespace Newtonsoft.Json.Tests.Converters
} }
}"; }";
Assert.AreEqual(expectedJson, json); StringAssert.AreEqual(expectedJson, json);
XmlNode node = JsonConvert.DeserializeXmlNode(json); XmlNode node = JsonConvert.DeserializeXmlNode(json);
@@ -2209,7 +2199,7 @@ namespace Newtonsoft.Json.Tests.Converters
<TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" /> <TextBlock Grid.Column=""0"" Text=""Assignee"" Style=""{StaticResource trimFormGrid_LBL}"" Grid.Row=""7"" xmlns="""" />
</Grid>"; </Grid>";
Assert.AreEqual(expectedXaml, xaml2); StringAssert.AreEqual(expectedXaml, xaml2);
} }
[Test] [Test]
@@ -127,7 +127,7 @@ namespace Newtonsoft.Json.Tests.Documentation
// ] // ]
#endregion #endregion
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""Name"": ""Joe Employee"", ""Name"": ""Joe Employee"",
""Manager"": { ""Manager"": {
@@ -159,7 +159,7 @@ namespace Newtonsoft.Json.Tests.Documentation
ContractResolver = ShouldSerializeContractResolver.Instance ContractResolver = ShouldSerializeContractResolver.Instance
}); });
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""Name"": ""Joe Employee"", ""Name"": ""Joe Employee"",
""Manager"": { ""Manager"": {
+7 -7
View File
@@ -67,7 +67,7 @@ namespace Newtonsoft.Json.Tests
string json = JsonConvert.SerializeObject(new { test = new[] { 1, 2, 3 } }); string json = JsonConvert.SerializeObject(new { test = new[] { 1, 2, 3 } });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""test"": [ ""test"": [
1, 1,
2, 2,
@@ -110,7 +110,7 @@ namespace Newtonsoft.Json.Tests
// "jobTitle": "Web Dude" // "jobTitle": "Web Dude"
// } // }
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""firstName"": ""Eric"", ""firstName"": ""Eric"",
""lastName"": ""Example"", ""lastName"": ""Example"",
""birthDate"": ""1980-04-20T00:00:00Z"", ""birthDate"": ""1980-04-20T00:00:00Z"",
@@ -193,7 +193,7 @@ namespace Newtonsoft.Json.Tests
JsonSerializer serializer = JsonSerializer.CreateDefault(); JsonSerializer serializer = JsonSerializer.CreateDefault();
serializer.Serialize(sw, l); serializer.Serialize(sw, l);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
1, 1,
2, 2,
3 3
@@ -242,7 +242,7 @@ namespace Newtonsoft.Json.Tests
}); });
serializer.Serialize(sw, l); serializer.Serialize(sw, l);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
2, 2,
4, 4,
6 6
@@ -252,7 +252,7 @@ namespace Newtonsoft.Json.Tests
serializer.Converters.Clear(); serializer.Converters.Clear();
serializer.Serialize(sw, l); serializer.Serialize(sw, l);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
1, 1,
2, 2,
3 3
@@ -262,7 +262,7 @@ namespace Newtonsoft.Json.Tests
serializer = JsonSerializer.Create(new JsonSerializerSettings { Formatting = Formatting.Indented }); serializer = JsonSerializer.Create(new JsonSerializerSettings { Formatting = Formatting.Indented });
serializer.Serialize(sw, l); serializer.Serialize(sw, l);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
1, 1,
2, 2,
3 3
@@ -890,7 +890,7 @@ namespace Newtonsoft.Json.Tests
#pragma warning restore 612,618 #pragma warning restore 612,618
task.Wait(); task.Wait();
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
1, 1,
2, 2,
3, 3,
+18 -18
View File
@@ -310,7 +310,7 @@ namespace Newtonsoft.Json.Tests
}"; }";
string result = sb.ToString(); string result = sb.ToString();
Assert.AreEqual(expected, result); StringAssert.AreEqual(expected, result);
} }
[Test] [Test]
@@ -349,7 +349,7 @@ namespace Newtonsoft.Json.Tests
}"; }";
string result = sb.ToString(); string result = sb.ToString();
Assert.AreEqual(expected, result); StringAssert.AreEqual(expected, result);
} }
[Test] [Test]
@@ -401,7 +401,7 @@ namespace Newtonsoft.Json.Tests
}"; }";
string result = sb.ToString(); string result = sb.ToString();
Assert.AreEqual(expected, result); StringAssert.AreEqual(expected, result);
} }
[Test] [Test]
@@ -480,7 +480,7 @@ namespace Newtonsoft.Json.Tests
]"; ]";
string result = sb.ToString(); string result = sb.ToString();
Assert.AreEqual(expected, result); StringAssert.AreEqual(expected, result);
} }
[Test] [Test]
@@ -528,7 +528,7 @@ namespace Newtonsoft.Json.Tests
]"; ]";
string result = sb.ToString(); string result = sb.ToString();
Assert.AreEqual(expected, result); StringAssert.AreEqual(expected, result);
} }
[Test] [Test]
@@ -564,7 +564,7 @@ namespace Newtonsoft.Json.Tests
]"; ]";
string result = sb.ToString(); string result = sb.ToString();
Assert.AreEqual(expected, result); StringAssert.AreEqual(expected, result);
} }
[Test] [Test]
@@ -601,7 +601,7 @@ namespace Newtonsoft.Json.Tests
]"; ]";
string result = sb.ToString(); string result = sb.ToString();
Assert.AreEqual(expected, result); StringAssert.AreEqual(expected, result);
} }
[Test] [Test]
@@ -627,7 +627,7 @@ namespace Newtonsoft.Json.Tests
]"; ]";
string result = sb.ToString(); string result = sb.ToString();
Assert.AreEqual(expected, result); StringAssert.AreEqual(expected, result);
} }
[Test] [Test]
@@ -655,7 +655,7 @@ namespace Newtonsoft.Json.Tests
]"; ]";
string result = sb.ToString(); string result = sb.ToString();
Assert.AreEqual(expected, result); StringAssert.AreEqual(expected, result);
} }
[Test] [Test]
@@ -804,7 +804,7 @@ namespace Newtonsoft.Json.Tests
Console.WriteLine(sb.ToString()); Console.WriteLine(sb.ToString());
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
2147483647, 2147483647,
-2147483648, -2147483648,
0, 0,
@@ -887,7 +887,7 @@ _____'propertyName': NaN
}"; }";
string result = sb.ToString(); string result = sb.ToString();
Assert.AreEqual(expected, result); StringAssert.AreEqual(expected, result);
} }
[Test] [Test]
@@ -949,7 +949,7 @@ _____'propertyName': NaN
]"; ]";
string result = sb.ToString(); string result = sb.ToString();
Assert.AreEqual(expected, result); StringAssert.AreEqual(expected, result);
} }
[Test] [Test]
@@ -1003,7 +1003,7 @@ _____'propertyName': NaN
Assert.AreEqual("", writer.Path); Assert.AreEqual("", writer.Path);
} }
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""Property1"": [ ""Property1"": [
1, 1,
@@ -1170,7 +1170,7 @@ _____'propertyName': NaN
writer.WriteEnd(); writer.WriteEnd();
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
'2000-01-01T01:01:01Z', '2000-01-01T01:01:01Z',
'2000-01-01T01:01:01+00:00', '2000-01-01T01:01:01+00:00',
'\/Date(946688461000)\/', '\/Date(946688461000)\/',
@@ -1201,7 +1201,7 @@ _____'propertyName': NaN
writer.WriteEnd(); writer.WriteEnd();
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
'2000 a.m.', '2000 a.m.',
'2000 a.m.' '2000 a.m.'
]", sw.ToString()); ]", sw.ToString());
@@ -1372,7 +1372,7 @@ _____'propertyName': NaN
writer.WriteEndObject(); writer.WriteEndObject();
Assert.AreEqual(WriteState.Start, writer.WriteState); Assert.AreEqual(WriteState.Start, writer.WriteState);
Assert.AreEqual(@"{{{ StringAssert.AreEqual(@"{{{
""1ytreporP"": NULL!!! ""1ytreporP"": NULL!!!
}}}", sw.ToString()); }}}", sw.ToString());
} }
@@ -1397,7 +1397,7 @@ _____'propertyName': NaN
writer.Close(); writer.Close();
} }
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
a: 1 a: 1
}", stringWriter.ToString()); }", stringWriter.ToString());
} }
@@ -1435,7 +1435,7 @@ null//comment
w.WriteToken(r, true); w.WriteToken(r, true);
Assert.AreEqual(@"/*comment*//*hi*/*/{/*comment*/ StringAssert.AreEqual(@"/*comment*//*hi*/*/{/*comment*/
""Name"": /*comment*/ true/*comment after true*//*comment after comma*/, ""Name"": /*comment*/ true/*comment after true*//*comment after comma*/,
""ExpiryDate"": /*comment*/ new Constructor( ""ExpiryDate"": /*comment*/ new Constructor(
/*comment*/, /*comment*/,
@@ -815,7 +815,7 @@ namespace Newtonsoft.Json.Tests.Linq
// "StockValue": 22050.00 // "StockValue": 22050.00
// } // }
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""ProductName"": ""Elbow Grease (SALE)"", ""ProductName"": ""Elbow Grease (SALE)"",
""Enabled"": true, ""Enabled"": true,
""Price"": 2.45, ""Price"": 2.45,
@@ -396,7 +396,7 @@ Parameter name: index");
string result = "myOptions = " + optionValues.ToString(); string result = "myOptions = " + optionValues.ToString();
Assert.AreEqual(@"myOptions = { StringAssert.AreEqual(@"myOptions = {
""options"": [ ""options"": [
{ {
""text"": ""Zero text"", ""text"": ""Zero text"",
+9 -21
View File
@@ -67,7 +67,7 @@ namespace Newtonsoft.Json.Tests.Linq
string output = o.ToString(); string output = o.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""title"": null ""title"": null
}", output); }", output);
@@ -101,7 +101,7 @@ namespace Newtonsoft.Json.Tests.Linq
var o = new JObject(); var o = new JObject();
o.Add(new JProperty("novalue")); o.Add(new JProperty("novalue"));
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""novalue"": null ""novalue"": null
}", o.ToString()); }", o.ToString());
} }
@@ -482,7 +482,7 @@ Parameter name: arrayIndex");
string json = o.ToString(); string json = o.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""val1"": 1, ""val1"": 1,
""val2"": 1 ""val2"": 1
}", json); }", json);
@@ -537,7 +537,7 @@ Parameter name: arrayIndex");
string output = o.ToString(); string output = o.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""title"": null ""title"": null
}", output); }", output);
} }
@@ -618,24 +618,12 @@ Parameter name: arrayIndex");
JObject o = new JObject(); JObject o = new JObject();
o["rc"] = new JValue(200); o["rc"] = new JValue(200);
o["m"] = new JValue(""); o["m"] = new JValue("");
o["o"] = new JValue(@"<div class='s1'> o["o"] = new JValue(@"<div class='s1'>" + StringUtils.CarriageReturnLineFeed + @"</div>");
<div class='avatar'>
<a href='asdf'>asdf</a><br />
<strong>0</strong>
</div>
<div class='sl'>
<p>
444444444
</p>
</div>
<div class='clear'>
</div>
</div>");
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""rc"": 200, ""rc"": 200,
""m"": """", ""m"": """",
""o"": ""<div class='s1'>\r\n <div class='avatar'> \r\n <a href='asdf'>asdf</a><br />\r\n <strong>0</strong>\r\n </div>\r\n <div class='sl'>\r\n <p>\r\n 444444444\r\n </p>\r\n </div>\r\n <div class='clear'>\r\n </div> \r\n</div>"" ""o"": ""<div class='s1'>\r\n</div>""
}", o.ToString()); }", o.ToString());
} }
@@ -1590,7 +1578,7 @@ Parameter name: arrayIndex");
string output = o.ToString(); string output = o.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""title"": null ""title"": null
}", output); }", output);
} }
@@ -1659,7 +1647,7 @@ Parameter name: arrayIndex");
JObject o = (JObject)JToken.ReadFrom(reader); JObject o = (JObject)JToken.ReadFrom(reader);
Assert.IsNotNull(o); Assert.IsNotNull(o);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""code"": 0, ""code"": 0,
""msg"": ""No action taken"" ""msg"": ""No action taken""
}", o.ToString(Formatting.Indented)); }", o.ToString(Formatting.Indented));
@@ -842,7 +842,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = a.ToString(Formatting.Indented, new IsoDateTimeConverter()); string json = a.ToString(Formatting.Indented, new IsoDateTimeConverter());
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""2009-02-15T00:00:00Z"" ""2009-02-15T00:00:00Z""
]", json); ]", json);
@@ -145,7 +145,7 @@ namespace Newtonsoft.Json.Tests.Linq
writer.WriteComment("fail"); writer.WriteComment("fail");
writer.WriteEndArray(); writer.WriteEndArray();
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
/*fail*/]", writer.Token.ToString()); /*fail*/]", writer.Token.ToString());
} }
@@ -164,7 +164,7 @@ namespace Newtonsoft.Json.Tests.Linq
Assert.AreEqual(new BigInteger(123), i.Value); Assert.AreEqual(new BigInteger(123), i.Value);
Assert.AreEqual(JTokenType.Integer, i.Type); Assert.AreEqual(JTokenType.Integer, i.Type);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
123 123
]", writer.Token.ToString()); ]", writer.Token.ToString());
} }
@@ -183,7 +183,7 @@ namespace Newtonsoft.Json.Tests.Linq
// this is a bug. write raw shouldn't be autocompleting like this // this is a bug. write raw shouldn't be autocompleting like this
// hard to fix without introducing Raw and RawValue token types // hard to fix without introducing Raw and RawValue token types
// meh // meh
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
fail, fail,
fail fail
]", writer.Token.ToString()); ]", writer.Token.ToString());
@@ -199,7 +199,7 @@ namespace Newtonsoft.Json.Tests.Linq
writer.WriteRawValue("fail"); writer.WriteRawValue("fail");
writer.WriteEndArray(); writer.WriteEndArray();
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
fail, fail,
fail fail
]", writer.Token.ToString()); ]", writer.Token.ToString());
@@ -399,7 +399,7 @@ namespace Newtonsoft.Json.Tests.Linq
var jTokenWriter = new JTokenWriter(); var jTokenWriter = new JTokenWriter();
new JsonSerializer().Serialize(jTokenWriter, rate); new JsonSerializer().Serialize(jTokenWriter, rate);
string json = jTokenWriter.Token.ToString(); string json = jTokenWriter.Token.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Compoundings"": 12.166666666666666666666666667 ""Compoundings"": 12.166666666666666666666666667
}", json); }", json);
} }
@@ -688,7 +688,7 @@ namespace Newtonsoft.Json.Tests.Linq
new JValue(1.1f) new JValue(1.1f)
); );
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""2013-02-01T01:02:03.004+01:00"", ""2013-02-01T01:02:03.004+01:00"",
5, 5,
1.1 1.1
@@ -744,7 +744,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = o.ToString(Formatting.Indented, new ReadOnlyStringConverter()); string json = o.ToString(Formatting.Indented, new ReadOnlyStringConverter());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""name"": ""Hello World"" ""name"": ""Hello World""
}", json); }", json);
} }
@@ -360,7 +360,7 @@ keyword such as type of business.""
JObject o = JObject.Parse(json); JObject o = JObject.Parse(json);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""CPU"": ""Intel"", ""CPU"": ""Intel"",
""Drives"": [ ""Drives"": [
""DVD read/writer"", ""DVD read/writer"",
@@ -370,7 +370,7 @@ keyword such as type of business.""
JArray list = o.Value<JArray>("Drives"); JArray list = o.Value<JArray>("Drives");
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""DVD read/writer"", ""DVD read/writer"",
""500 gigabyte hard drive"" ""500 gigabyte hard drive""
]", list.ToString()); ]", list.ToString());
@@ -379,7 +379,7 @@ keyword such as type of business.""
Assert.AreEqual(@"""CPU"": ""Intel""", cpuProperty.ToString()); Assert.AreEqual(@"""CPU"": ""Intel""", cpuProperty.ToString());
JProperty drivesProperty = o.Property("Drives"); JProperty drivesProperty = o.Property("Drives");
Assert.AreEqual(@"""Drives"": [ StringAssert.AreEqual(@"""Drives"": [
""DVD read/writer"", ""DVD read/writer"",
""500 gigabyte hard drive"" ""500 gigabyte hard drive""
]", drivesProperty.ToString()); ]", drivesProperty.ToString());
@@ -392,10 +392,10 @@ keyword such as type of business.""
JObject o = JObject.Parse(json); JObject o = JObject.Parse(json);
Assert.AreEqual(@"""Establised"": new Date( StringAssert.AreEqual(@"""Establised"": new Date(
1264118400000 1264118400000
)", o.Property("Establised").ToString()); )", o.Property("Establised").ToString());
Assert.AreEqual(@"new Date( StringAssert.AreEqual(@"new Date(
1264118400000 1264118400000
)", o.Property("Establised").Value.ToString()); )", o.Property("Establised").Value.ToString());
Assert.AreEqual(@"""Width"": 1.1", o.Property("Width").ToString()); Assert.AreEqual(@"""Width"": 1.1", o.Property("Width").ToString());
@@ -406,7 +406,7 @@ keyword such as type of business.""
json = @"[null,undefined]"; json = @"[null,undefined]";
JArray a = JArray.Parse(json); JArray a = JArray.Parse(json);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
null, null,
undefined undefined
]", a.ToString()); ]", a.ToString());
@@ -427,7 +427,7 @@ keyword such as type of business.""
Assert.AreEqual(4, o.Properties().Count()); Assert.AreEqual(4, o.Properties().Count());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Test1"": ""Test1Value"", ""Test1"": ""Test1Value"",
""Test2"": ""Test2Value"", ""Test2"": ""Test2Value"",
""Test3"": ""Test3Value"", ""Test3"": ""Test3Value"",
@@ -454,7 +454,7 @@ keyword such as type of business.""
); );
Assert.AreEqual(5, a.Count()); Assert.AreEqual(5, a.Count());
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""Test1"": ""Test1Value"", ""Test1"": ""Test1Value"",
""Test2"": ""Test2Value"", ""Test2"": ""Test2Value"",
@@ -531,7 +531,7 @@ keyword such as type of business.""
// ] // ]
// } // }
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Title"": ""How to use FromObject - Super effective!"", ""Title"": ""How to use FromObject - Super effective!"",
""Description"": null, ""Description"": null,
""Link"": null, ""Link"": null,
@@ -758,7 +758,7 @@ keyword such as type of business.""
string json = sw.ToString(); string json = sw.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Test1"": new Date( ""Test1"": new Date(
971586305000 971586305000
), ),
@@ -995,7 +995,7 @@ keyword such as type of business.""
UriGuidTimeSpanTestClass c1 = new UriGuidTimeSpanTestClass(); UriGuidTimeSpanTestClass c1 = new UriGuidTimeSpanTestClass();
JObject o = JObject.FromObject(c1); JObject o = JObject.FromObject(c1);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Guid"": ""00000000-0000-0000-0000-000000000000"", ""Guid"": ""00000000-0000-0000-0000-000000000000"",
""NullableGuid"": null, ""NullableGuid"": null,
""TimeSpan"": ""00:00:00"", ""TimeSpan"": ""00:00:00"",
@@ -1024,7 +1024,7 @@ keyword such as type of business.""
}; };
JObject o = JObject.FromObject(c1); JObject o = JObject.FromObject(c1);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Guid"": ""1924129c-f7e0-40f3-9607-9939c531395a"", ""Guid"": ""1924129c-f7e0-40f3-9607-9939c531395a"",
""NullableGuid"": ""9e9f3adf-e017-4f72-91e0-617ebe85967d"", ""NullableGuid"": ""9e9f3adf-e017-4f72-91e0-617ebe85967d"",
""TimeSpan"": ""1.00:00:00"", ""TimeSpan"": ""1.00:00:00"",
+11 -11
View File
@@ -30,7 +30,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = left.ToString(); string json = left.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Property1"": 1, ""Property1"": 1,
""Property2"": 2 ""Property2"": 2
}", json); }", json);
@@ -52,7 +52,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = left.ToString(); string json = left.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Property1"": { ""Property1"": {
""SubProperty1"": 1, ""SubProperty1"": 1,
""SubProperty2"": 2 ""SubProperty2"": 2
@@ -77,7 +77,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = left.ToString(); string json = left.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Property1"": { ""Property1"": {
""SubProperty1"": 1 ""SubProperty1"": 1
} }
@@ -101,7 +101,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = left.ToString(); string json = left.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Property1"": { ""Property1"": {
""SubProperty1"": 1, ""SubProperty1"": 1,
""SubProperty2"": 2 ""SubProperty2"": 2
@@ -171,7 +171,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = left.ToString(); string json = left.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Array1"": [ ""Array1"": [
{ {
""Property1"": { ""Property1"": {
@@ -222,7 +222,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = left.ToString(); string json = left.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Array1"": [ ""Array1"": [
{ {
""Property1"": 1 ""Property1"": 1
@@ -274,7 +274,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = left.ToString(); string json = left.ToString();
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
1, 1,
5, 5,
{ {
@@ -326,7 +326,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = left.ToString(); string json = left.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Property1"": { ""Property1"": {
""Nested"": true ""Nested"": true
}, },
@@ -366,7 +366,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = left.ToString(); string json = left.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Array1"": [ ""Array1"": [
4, 4,
5 5
@@ -396,7 +396,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = left.ToString(); string json = left.ToString();
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
4, 4,
5 5
]", json); ]", json);
@@ -430,7 +430,7 @@ namespace Newtonsoft.Json.Tests.Linq
string json = left.ToString(); string json = left.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Array1"": [ ""Array1"": [
{ {
""Property1"": 1 ""Property1"": 1
@@ -64,7 +64,7 @@ namespace Newtonsoft.Json.Tests.LinqToSql
string json = JsonConvert.SerializeObject(person, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); string json = JsonConvert.SerializeObject(person, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""first_name"": ""FirstName!"", ""first_name"": ""FirstName!"",
""LastName"": ""LastName!"", ""LastName"": ""LastName!"",
""PersonId"": ""7aa027aa-c995-4986-908d-999d8063599f"", ""PersonId"": ""7aa027aa-c995-4986-908d-999d8063599f"",
@@ -63,7 +63,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = schema.ToString(); string json = schema.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""type"": ""object"", ""type"": ""object"",
""additionalProperties"": { ""additionalProperties"": {
""type"": [ ""type"": [
@@ -100,7 +100,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = schema.ToString(); string json = schema.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""description"": ""DefaultValueAttributeTestClass description!"", ""description"": ""DefaultValueAttributeTestClass description!"",
""type"": ""object"", ""type"": ""object"",
""additionalProperties"": false, ""additionalProperties"": false,
@@ -131,7 +131,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = schema.ToString(); string json = schema.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""id"": ""Person"", ""id"": ""Person"",
""title"": ""Title!"", ""title"": ""Title!"",
""description"": ""JsonObjectAttribute description!"", ""description"": ""JsonObjectAttribute description!"",
@@ -164,7 +164,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = schema.ToString(); string json = schema.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""type"": ""object"", ""type"": ""object"",
""properties"": { ""properties"": {
""Id"": { ""Id"": {
@@ -379,7 +379,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = schema.ToString(); string json = schema.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""id"": ""System.IO.DirectoryInfo"", ""id"": ""System.IO.DirectoryInfo"",
""required"": true, ""required"": true,
""type"": [ ""type"": [
@@ -483,7 +483,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = schema.ToString(); string json = schema.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""id"": ""System.Version"", ""id"": ""System.Version"",
""type"": [ ""type"": [
""object"", ""object"",
@@ -534,7 +534,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = schema.ToString(); string json = schema.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""id"": ""System.Version"", ""id"": ""System.Version"",
""type"": [ ""type"": [
""object"", ""object"",
@@ -574,7 +574,7 @@ namespace Newtonsoft.Json.Tests.Schema
Assert.AreEqual(0, errors.Count); Assert.AreEqual(0, errors.Count);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""_Major"": 1, ""_Major"": 1,
""_Minor"": 2, ""_Minor"": 2,
""_Build"": 3, ""_Build"": 3,
@@ -609,7 +609,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = schema.ToString(); string json = schema.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""type"": ""object"", ""type"": ""object"",
""properties"": { ""properties"": {
""x"": { ""x"": {
@@ -647,7 +647,7 @@ namespace Newtonsoft.Json.Tests.Schema
JsonSchema jsonSchema = jsonSchemaGenerator.Generate(typeof(CircularReferenceClass)); JsonSchema jsonSchema = jsonSchemaGenerator.Generate(typeof(CircularReferenceClass));
string json = jsonSchema.ToString(); string json = jsonSchema.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""id"": ""Newtonsoft.Json.Tests.TestObjects.CircularReferenceClass"", ""id"": ""Newtonsoft.Json.Tests.TestObjects.CircularReferenceClass"",
""type"": [ ""type"": [
""object"", ""object"",
@@ -674,7 +674,7 @@ namespace Newtonsoft.Json.Tests.Schema
JsonSchema jsonSchema = jsonSchemaGenerator.Generate(typeof(JsonPropertyWithHandlingValues)); JsonSchema jsonSchema = jsonSchemaGenerator.Generate(typeof(JsonPropertyWithHandlingValues));
string json = jsonSchema.ToString(); string json = jsonSchema.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""id"": ""Newtonsoft.Json.Tests.TestObjects.JsonPropertyWithHandlingValues"", ""id"": ""Newtonsoft.Json.Tests.TestObjects.JsonPropertyWithHandlingValues"",
""required"": true, ""required"": true,
""type"": [ ""type"": [
@@ -746,7 +746,7 @@ namespace Newtonsoft.Json.Tests.Schema
JsonSchema jsonSchema = jsonSchemaGenerator.Generate(typeof(NullableInt32TestClass)); JsonSchema jsonSchema = jsonSchemaGenerator.Generate(typeof(NullableInt32TestClass));
string json = jsonSchema.ToString(); string json = jsonSchema.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""type"": ""object"", ""type"": ""object"",
""properties"": { ""properties"": {
""Value"": { ""Value"": {
@@ -86,7 +86,7 @@ namespace Newtonsoft.Json.Tests.Schema
third.WriteTo(jsonWriter, resolver); third.WriteTo(jsonWriter, resolver);
string writtenJson = writer.ToString(); string writtenJson = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""id"": ""third"", ""id"": ""third"",
""type"": ""object"", ""type"": ""object"",
""additionalProperties"": false, ""additionalProperties"": false,
@@ -102,7 +102,7 @@ namespace Newtonsoft.Json.Tests.Schema
third.WriteTo(jsonWriter1); third.WriteTo(jsonWriter1);
writtenJson = writer1.ToString(); writtenJson = writer1.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""id"": ""third"", ""id"": ""third"",
""type"": ""object"", ""type"": ""object"",
""additionalProperties"": false, ""additionalProperties"": false,
@@ -138,7 +138,7 @@ namespace Newtonsoft.Json.Tests.Schema
string newJson = s.ToString(); string newJson = s.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""type"": ""object"", ""type"": ""object"",
""additionalProperties"": { ""additionalProperties"": {
""type"": ""string"" ""type"": ""string""
@@ -163,7 +163,7 @@ namespace Newtonsoft.Json.Tests.Schema
newJson = s.ToString(); newJson = s.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""type"": ""object"", ""type"": ""object"",
""additionalProperties"": { ""additionalProperties"": {
""type"": ""string"" ""type"": ""string""
@@ -188,7 +188,7 @@ namespace Newtonsoft.Json.Tests.Schema
newJson = s.ToString(); newJson = s.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""type"": ""object"", ""type"": ""object"",
""additionalProperties"": { ""additionalProperties"": {
""type"": ""string"" ""type"": ""string""
@@ -221,7 +221,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = writer.ToString(); string json = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""description"": ""AdditionalProperties"", ""description"": ""AdditionalProperties"",
""type"": [ ""type"": [
""string"", ""string"",
@@ -261,7 +261,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = writer.ToString(); string json = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""description"": ""A person"", ""description"": ""A person"",
""type"": ""object"", ""type"": ""object"",
""properties"": { ""properties"": {
@@ -296,7 +296,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = writer.ToString(); string json = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""description"": ""Type"", ""description"": ""Type"",
""type"": [ ""type"": [
""string"", ""string"",
@@ -336,7 +336,7 @@ namespace Newtonsoft.Json.Tests.Schema
string writtenJson = writer.ToString(); string writtenJson = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""id"": ""CircularReferenceArray"", ""id"": ""CircularReferenceArray"",
""description"": ""CircularReference"", ""description"": ""CircularReference"",
""type"": ""array"", ""type"": ""array"",
@@ -364,7 +364,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = writer.ToString(); string json = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""description"": ""Type"", ""description"": ""Type"",
""type"": [ ""type"": [
""string"", ""string"",
@@ -397,7 +397,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = writer.ToString(); string json = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""description"": ""Type"", ""description"": ""Type"",
""type"": [ ""type"": [
""string"", ""string"",
@@ -423,7 +423,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = writer.ToString(); string json = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""items"": [ ""items"": [
{}, {},
{} {}
@@ -446,7 +446,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = writer.ToString(); string json = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""exclusiveMinimum"": true, ""exclusiveMinimum"": true,
""exclusiveMaximum"": true ""exclusiveMaximum"": true
}", json); }", json);
@@ -469,7 +469,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = writer.ToString(); string json = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""patternProperties"": { ""patternProperties"": {
""[abc]"": {} ""[abc]"": {}
} }
@@ -485,7 +485,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = schema.ToString(); string json = schema.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""additionalItems"": { ""additionalItems"": {
""type"": ""integer"" ""type"": ""integer""
} }
@@ -506,7 +506,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = writer.ToString(); string json = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""items"": [] ""items"": []
}", json); }", json);
} }
@@ -526,7 +526,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = writer.ToString(); string json = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""items"": [ ""items"": [
{ {
""type"": ""string"" ""type"": ""string""
@@ -549,7 +549,7 @@ namespace Newtonsoft.Json.Tests.Schema
string json = writer.ToString(); string json = writer.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""items"": { ""items"": {
""type"": ""string"" ""type"": ""string""
} }
@@ -56,7 +56,7 @@ namespace Newtonsoft.Json.Tests.Serialization
ContractResolver = new CamelCasePropertyNamesContractResolver() ContractResolver = new CamelCasePropertyNamesContractResolver()
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""name"": ""Name!"", ""name"": ""Name!"",
""birthDate"": ""2000-11-20T23:55:44Z"", ""birthDate"": ""2000-11-20T23:55:44Z"",
""lastModified"": ""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); Assert.AreEqual(person.Name, deserializedPerson.Name);
json = JsonConvert.SerializeObject(person, Formatting.Indented); json = JsonConvert.SerializeObject(person, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""Name!"", ""Name"": ""Name!"",
""BirthDate"": ""2000-11-20T23:55:44Z"", ""BirthDate"": ""2000-11-20T23:55:44Z"",
""LastModified"": ""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 } ContractResolver = new CamelCasePropertyNamesContractResolver { DefaultMembersSearchFlags = BindingFlags.NonPublic | BindingFlags.Instance }
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""_privateString"": ""PrivateString!"", ""_privateString"": ""PrivateString!"",
""i"": 0, ""i"": 0,
""_internalString"": ""InternalString!"" ""_internalString"": ""InternalString!""
@@ -166,7 +166,7 @@ namespace Newtonsoft.Json.Tests.Serialization
// ] // ]
//} //}
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""name"": ""Widget"", ""name"": ""Widget"",
""expiryDate"": ""2010-12-20T18:01:00Z"", ""expiryDate"": ""2010-12-20T18:01:00Z"",
""price"": 9.99, ""price"": 9.99,
@@ -192,7 +192,7 @@ namespace Newtonsoft.Json.Tests.Serialization
ContractResolver = new CamelCasePropertyNamesContractResolver() ContractResolver = new CamelCasePropertyNamesContractResolver()
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""explicit"": false, ""explicit"": false,
""text"": ""Text!"", ""text"": ""Text!"",
""integer"": 2147483647, ""integer"": 2147483647,
@@ -217,7 +217,7 @@ namespace Newtonsoft.Json.Tests.Serialization
ContractResolver = new CamelCasePropertyNamesContractResolver() ContractResolver = new CamelCasePropertyNamesContractResolver()
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""first"": ""Value1!"", ""first"": ""Value1!"",
""second"": ""Value2!"" ""second"": ""Value2!""
}", json); }", json);
@@ -499,7 +499,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string iPersonJson = JsonConvert.SerializeObject(employee, Formatting.Indented, string iPersonJson = JsonConvert.SerializeObject(employee, Formatting.Indented,
new JsonSerializerSettings { ContractResolver = new IPersonContractResolver() }); new JsonSerializerSettings { ContractResolver = new IPersonContractResolver() });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""FirstName"": ""Maurice"", ""FirstName"": ""Maurice"",
""LastName"": ""Moss"", ""LastName"": ""Moss"",
""BirthDate"": ""1977-12-30T01:01:01Z"" ""BirthDate"": ""1977-12-30T01:01:01Z""
@@ -535,13 +535,13 @@ namespace Newtonsoft.Json.Tests.Serialization
// "BookPrice": 16.19 // "BookPrice": 16.19
// } // }
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""AuthorName"": ""Brandon Sanderson"", ""AuthorName"": ""Brandon Sanderson"",
""AuthorAge"": 34, ""AuthorAge"": 34,
""AuthorCountry"": ""United States of America"" ""AuthorCountry"": ""United States of America""
}", startingWithA); }", startingWithA);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""BookName"": ""The Gathering Storm"", ""BookName"": ""The Gathering Storm"",
""BookPrice"": 16.19 ""BookPrice"": 16.19
}", startingWithB); }", startingWithB);
@@ -568,7 +568,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string skipCompilerGeneratedJson = JsonConvert.SerializeObject(structTest, Formatting.Indented, string skipCompilerGeneratedJson = JsonConvert.SerializeObject(structTest, Formatting.Indented,
new JsonSerializerSettings { ContractResolver = skipCompilerGeneratedResolver }); new JsonSerializerSettings { ContractResolver = skipCompilerGeneratedResolver });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""StringField"": ""Field"", ""StringField"": ""Field"",
""IntField"": 1, ""IntField"": 1,
""StringProperty"": ""Property"", ""StringProperty"": ""Property"",
@@ -584,7 +584,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string includeCompilerGeneratedJson = JsonConvert.SerializeObject(structTest, Formatting.Indented, string includeCompilerGeneratedJson = JsonConvert.SerializeObject(structTest, Formatting.Indented,
new JsonSerializerSettings { ContractResolver = includeCompilerGeneratedResolver }); new JsonSerializerSettings { ContractResolver = includeCompilerGeneratedResolver });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""StringField"": ""Field"", ""StringField"": ""Field"",
""IntField"": 1, ""IntField"": 1,
""<StringProperty>k__BackingField"": ""Property"", ""<StringProperty>k__BackingField"": ""Property"",
@@ -99,7 +99,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting.Indented, Formatting.Indented,
new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Include }); new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Include });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Company"": ""Acme Ltd."", ""Company"": ""Acme Ltd."",
""Amount"": 50.0, ""Amount"": 50.0,
""Paid"": false, ""Paid"": false,
@@ -126,7 +126,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting.Indented, Formatting.Indented,
new JsonSerializerSettings { }); new JsonSerializerSettings { });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Company"": ""Acme Ltd."", ""Company"": ""Acme Ltd."",
""Amount"": 50.0, ""Amount"": 50.0,
""Paid"": false, ""Paid"": false,
@@ -139,7 +139,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting.Indented, Formatting.Indented,
new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore }); new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Company"": ""Acme Ltd."", ""Company"": ""Acme Ltd."",
""Amount"": 50.0 ""Amount"": 50.0
}", ignored); }", ignored);
@@ -295,7 +295,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c, Formatting.Indented); string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""IntInclude"": 0, ""IntInclude"": 0,
""IntDefault"": 0 ""IntDefault"": 0
}", json); }", json);
@@ -305,7 +305,7 @@ namespace Newtonsoft.Json.Tests.Serialization
DefaultValueHandling = DefaultValueHandling.Ignore DefaultValueHandling = DefaultValueHandling.Ignore
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""IntInclude"": 0 ""IntInclude"": 0
}", json); }", json);
@@ -314,7 +314,7 @@ namespace Newtonsoft.Json.Tests.Serialization
DefaultValueHandling = DefaultValueHandling.Include DefaultValueHandling = DefaultValueHandling.Include
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""IntInclude"": 0, ""IntInclude"": 0,
""IntDefault"": 0 ""IntDefault"": 0
}", json); }", json);
@@ -80,7 +80,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(d.ChildObject, values["ChildObject"]); Assert.AreEqual(d.ChildObject, values["ChildObject"]);
string json = JsonConvert.SerializeObject(dynamicObject, Formatting.Indented); string json = JsonConvert.SerializeObject(dynamicObject, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Explicit"": true, ""Explicit"": true,
""Decimal"": 99.9, ""Decimal"": 99.9,
""Int"": 1, ""Int"": 1,
@@ -125,7 +125,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string dynamicChildObjectTypeName = ReflectionUtils.GetTypeName(typeof(DynamicChildObject), FormatterAssemblyStyle.Full, null); string dynamicChildObjectTypeName = ReflectionUtils.GetTypeName(typeof(DynamicChildObject), FormatterAssemblyStyle.Full, null);
string expandoObjectTypeName = ReflectionUtils.GetTypeName(typeof(ExpandoObject), FormatterAssemblyStyle.Full, null); string expandoObjectTypeName = ReflectionUtils.GetTypeName(typeof(ExpandoObject), FormatterAssemblyStyle.Full, null);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$type"": """ + expandoObjectTypeName + @""", ""$type"": """ + expandoObjectTypeName + @""",
""Text"": ""Text!"", ""Text"": ""Text!"",
""Integer"": 2147483647, ""Integer"": 2147483647,
@@ -267,7 +267,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Console.WriteLine(json); Console.WriteLine(json);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Explicit"": false, ""Explicit"": false,
""Text"": ""Text!"", ""Text"": ""Text!"",
""Int"": 2147483647 ""Int"": 2147483647
@@ -290,7 +290,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Console.WriteLine(json); Console.WriteLine(json);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Explicit"": false, ""Explicit"": false,
""Text"": ""Text!"", ""Text"": ""Text!"",
""DynamicChildObject"": null, ""DynamicChildObject"": null,
@@ -317,7 +317,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Console.WriteLine(json); Console.WriteLine(json);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Text"": ""Text!"", ""Text"": ""Text!"",
""Int"": 2147483647 ""Int"": 2147483647
}", json); }", json);
@@ -123,7 +123,7 @@ namespace Newtonsoft.Json.Tests.Serialization
} }
}"; }";
Assert.AreEqual(expected, json); StringAssert.AreEqual(expected, json);
} }
[Test] [Test]
@@ -213,7 +213,7 @@ namespace Newtonsoft.Json.Tests.Serialization
} }
}"; }";
Assert.AreEqual(expected, json); StringAssert.AreEqual(expected, json);
} }
[Test] [Test]
@@ -337,7 +337,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(e, settings); string json = JsonConvert.SerializeObject(e, settings);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$id"": ""1"", ""$id"": ""1"",
""entitySetName"": ""Folder"", ""entitySetName"": ""Folder"",
""entityContainerName"": ""DataServicesTestDatabaseEntities"", ""entityContainerName"": ""DataServicesTestDatabaseEntities"",
@@ -401,7 +401,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(e, Formatting.Indented); string json = JsonConvert.SerializeObject(e, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$id"": ""1"", ""$id"": ""1"",
""EntitySetName"": ""Folder"", ""EntitySetName"": ""Folder"",
""EntityContainerName"": ""DataServicesTestDatabaseEntities"", ""EntityContainerName"": ""DataServicesTestDatabaseEntities"",
@@ -65,7 +65,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c, Formatting.Indented); string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""Name!"", ""Name"": ""Name!"",
""Key!"": ""Value!"" ""Key!"": ""Value!""
}", json); }", json);
@@ -392,7 +392,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting = Formatting.Indented Formatting = Formatting.Indented
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$id"": ""1"", ""$id"": ""1"",
""Name"": ""Name!"", ""Name"": ""Name!"",
""Test"": 1, ""Test"": 1,
@@ -520,7 +520,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting = Formatting.Indented Formatting = Formatting.Indented
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$type"": ""Newtonsoft.Json.Tests.Serialization.ExtensionDataTests+PublicExtensionDataAttributeTestClass, Newtonsoft.Json.Tests"", ""$type"": ""Newtonsoft.Json.Tests.Serialization.ExtensionDataTests+PublicExtensionDataAttributeTestClass, Newtonsoft.Json.Tests"",
""Name"": ""Name!"", ""Name"": ""Name!"",
""Test"": { ""Test"": {
@@ -44,7 +44,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
1, 1,
2, 2,
3 3
@@ -63,7 +63,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
1, 1,
2, 2,
3 3
@@ -56,7 +56,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}); });
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""One"", ""One"",
""II"", ""II"",
""3"" ""3""
@@ -114,7 +114,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}); });
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""One"", ""One"",
""II"", ""II"",
""3"" ""3""
@@ -162,7 +162,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}); });
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""One"", ""One"",
""II"", ""II"",
""3"" ""3""
@@ -216,7 +216,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}); });
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""3"", ""3"",
""II"", ""II"",
""One"" ""One""
@@ -325,7 +325,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}); });
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""3"", ""3"",
""II"", ""II"",
""One"" ""One""
@@ -416,7 +416,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}); });
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""1"": ""One"", ""1"": ""One"",
""2"": ""II"", ""2"": ""II"",
""3"": ""3"" ""3"": ""3""
@@ -309,7 +309,7 @@ namespace Newtonsoft.Json.Tests.Serialization
CustomReadOnlyDictionary<string, int> dic = new CustomReadOnlyDictionary<string, int>(d); CustomReadOnlyDictionary<string, int> dic = new CustomReadOnlyDictionary<string, int>(d);
string json = JsonConvert.SerializeObject(dic, Formatting.Indented); string json = JsonConvert.SerializeObject(dic, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""one"": 1, ""one"": 1,
""two"": 2 ""two"": 2
}", json); }", json);
@@ -353,7 +353,7 @@ namespace Newtonsoft.Json.Tests.Serialization
CustomReadOnlyCollection<int> list = new CustomReadOnlyCollection<int>(l); CustomReadOnlyCollection<int> list = new CustomReadOnlyCollection<int>(l);
string json = JsonConvert.SerializeObject(list, Formatting.Indented); string json = JsonConvert.SerializeObject(list, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
1, 1,
2, 2,
3 3
@@ -442,7 +442,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(list, Formatting.Indented); string json = JsonConvert.SerializeObject(list, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""Key"": ""key1"", ""Key"": ""key1"",
""Value"": { ""Value"": {
@@ -528,7 +528,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(v1, Formatting.Indented); string json = JsonConvert.SerializeObject(v1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""First"": 1, ""First"": 1,
""Second"": null, ""Second"": null,
""Third"": 3 ""Third"": 3
@@ -558,7 +558,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string originalJson = JsonConvert.SerializeObject(go, Formatting.Indented); string originalJson = JsonConvert.SerializeObject(go, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Components"": { ""Components"": {
""Key!"": {} ""Key!"": {}
}, },
@@ -663,7 +663,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c1, Formatting.Indented); string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""NonReadOnlyList"": [ ""NonReadOnlyList"": [
1 1
], ],
@@ -783,7 +783,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(aa, Formatting.Indented); string json = JsonConvert.SerializeObject(aa, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Before"": ""Before!"", ""Before"": ""Before!"",
""Coordinates"": [ ""Coordinates"": [
[ [
@@ -1088,7 +1088,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting = Formatting.Indented Formatting = Formatting.Indented
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$id"": ""1"", ""$id"": ""1"",
""$values"": [ ""$values"": [
{ {
@@ -1142,7 +1142,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting = Formatting.Indented Formatting = Formatting.Indented
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$type"": ""System.Collections.Generic.List`1[[Newtonsoft.Json.Tests.TestObjects.Event1[,], Newtonsoft.Json.Tests]], mscorlib"", ""$type"": ""System.Collections.Generic.List`1[[Newtonsoft.Json.Tests.TestObjects.Event1[,], Newtonsoft.Json.Tests]], mscorlib"",
""$values"": [ ""$values"": [
{ {
@@ -1281,7 +1281,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(name, Formatting.Indented); string json = JsonConvert.SerializeObject(name, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""personsName"": ""The Idiot in Next To Me"", ""personsName"": ""The Idiot in Next To Me"",
""pNumbers"": [ ""pNumbers"": [
{ {
@@ -1420,7 +1420,7 @@ namespace Newtonsoft.Json.Tests.Serialization
// } // }
//] //]
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""Name"": ""Product 1"", ""Name"": ""Product 1"",
""ExpiryDate"": ""2000-12-29T00:00:00Z"", ""ExpiryDate"": ""2000-12-29T00:00:00Z"",
@@ -1482,7 +1482,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
1, 1,
2, 2,
3, 3,
@@ -682,7 +682,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(null, v.Value); Assert.AreEqual(null, v.Value);
Assert.AreEqual(JTokenType.String, v.Type); Assert.AreEqual(JTokenType.String, v.Type);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""title"": null ""title"": null
}", output); }", output);
} }
@@ -954,7 +954,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = AssertSerializeDeserializeEqual(baseWith); string json = AssertSerializeDeserializeEqual(baseWith);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""JustAProperty"": ""JustAProperty2!"", ""JustAProperty"": ""JustAProperty2!"",
""Virtual"": ""Virtual2!"", ""Virtual"": ""Virtual2!"",
""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"", ""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"",
@@ -984,7 +984,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Console.WriteLine(json); Console.WriteLine(json);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"", ""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"",
""VirtualSub"": ""Virtual2!"", ""VirtualSub"": ""Virtual2!"",
""WithDataMemberBase"": ""WithDataMember2!"", ""WithDataMemberBase"": ""WithDataMember2!"",
@@ -1010,7 +1010,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = AssertSerializeDeserializeEqual(baseWith); string json = AssertSerializeDeserializeEqual(baseWith);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""JustAProperty"": ""JustAProperty2!"", ""JustAProperty"": ""JustAProperty2!"",
""JustAProperty2"": ""JustAProperty!"", ""JustAProperty2"": ""JustAProperty!"",
""Virtual"": ""Virtual2!"", ""Virtual"": ""Virtual2!"",
@@ -1040,7 +1040,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = AssertSerializeDeserializeEqual(baseWith); string json = AssertSerializeDeserializeEqual(baseWith);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""JustAProperty"": ""JustAProperty2!"", ""JustAProperty"": ""JustAProperty2!"",
""Virtual"": ""Virtual2!"", ""Virtual"": ""Virtual2!"",
""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"", ""VirtualWithDataMemberBase"": ""VirtualWithDataMember2!"",
@@ -1215,7 +1215,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypedSubHashtable p = JsonConvert.DeserializeObject(value, typeof(TypedSubHashtable)) as TypedSubHashtable; TypedSubHashtable p = JsonConvert.DeserializeObject(value, typeof(TypedSubHashtable)) as TypedSubHashtable;
Assert.AreEqual("01/24/2010 12:00:00", p.Hash["ExpiryDate"].ToString()); Assert.AreEqual("01/24/2010 12:00:00", p.Hash["ExpiryDate"].ToString());
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""01/24/2010 12:00:00"" ""01/24/2010 12:00:00""
]", p.Hash["UntypedArray"].ToString()); ]", p.Hash["UntypedArray"].ToString());
} }
@@ -1671,7 +1671,7 @@ keyword such as type of business.""
}"; }";
#endif #endif
Assert.AreEqual(expected, json); StringAssert.AreEqual(expected, json);
ConverableMembers c = JsonConvert.DeserializeObject<ConverableMembers>(json); ConverableMembers c = JsonConvert.DeserializeObject<ConverableMembers>(json);
Assert.AreEqual("string", c.String); Assert.AreEqual("string", c.String);
@@ -1747,7 +1747,7 @@ keyword such as type of business.""
TimeSpan ts = new TimeSpan(00, 23, 59, 1); TimeSpan ts = new TimeSpan(00, 23, 59, 1);
string json = JsonConvert.SerializeObject(new ClassWithTimeSpan { TimeSpanField = ts }, Formatting.Indented); string json = JsonConvert.SerializeObject(new ClassWithTimeSpan { TimeSpanField = ts }, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""TimeSpanField"": ""23:59:01"" ""TimeSpanField"": ""23:59:01""
}", json); }", json);
@@ -2062,7 +2062,7 @@ keyword such as type of business.""
string json = JsonConvert.SerializeObject(c, Formatting.Indented); string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""FirstName"": ""Bob"", ""FirstName"": ""Bob"",
""MiddleName"": ""Cosmo"", ""MiddleName"": ""Cosmo"",
""LastName"": ""Smith"", ""LastName"": ""Smith"",
@@ -2447,7 +2447,7 @@ keyword such as type of business.""
string json = JsonConvert.SerializeObject(o, Formatting.Indented); string json = JsonConvert.SerializeObject(o, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""DefaultValueHandlingIncludeProperty"": ""Default!"", ""DefaultValueHandlingIncludeProperty"": ""Default!"",
""DefaultValueHandlingPopulateProperty"": ""Default!"", ""DefaultValueHandlingPopulateProperty"": ""Default!"",
""NullValueHandlingIncludeProperty"": null, ""NullValueHandlingIncludeProperty"": null,
@@ -2458,7 +2458,7 @@ keyword such as type of business.""
json = JsonConvert.SerializeObject(o, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); json = JsonConvert.SerializeObject(o, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""DefaultValueHandlingIncludeProperty"": ""Default!"", ""DefaultValueHandlingIncludeProperty"": ""Default!"",
""DefaultValueHandlingPopulateProperty"": ""Default!"", ""DefaultValueHandlingPopulateProperty"": ""Default!"",
""NullValueHandlingIncludeProperty"": null ""NullValueHandlingIncludeProperty"": null
@@ -2554,7 +2554,7 @@ keyword such as type of business.""
string json = JsonConvert.SerializeObject(optInClass, Formatting.Indented); string json = JsonConvert.SerializeObject(optInClass, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""James NK"", ""Name"": ""James NK"",
""Age"": 26 ""Age"": 26
}", json); }", json);
@@ -2614,7 +2614,7 @@ keyword such as type of business.""
c.NotIncluded = "Hi"; c.NotIncluded = "Hi";
string json = JsonConvert.SerializeObject(c, Formatting.Indented); string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""_name"": ""Jeff"", ""_name"": ""Jeff"",
""_age"": 26, ""_age"": 26,
""Rank"": 10, ""Rank"": 10,
@@ -2771,7 +2771,7 @@ keyword such as type of business.""
string json = JsonConvert.SerializeObject(content, Formatting.Indented); string json = JsonConvert.SerializeObject(content, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Children"": [ ""Children"": [
{ {
""Children"": null, ""Children"": null,
@@ -2939,7 +2939,9 @@ Path '', line 1, position 1.");
{ {
string json = @"[]"; 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. 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."); Path '', line 1, position 1.");
} }
@@ -2986,9 +2988,9 @@ Path '', line 1, position 1.");
} }
catch (JsonSerializationException ex) 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. 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. @"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 ''")); @"Path ''"));
} }
} }
@@ -3103,7 +3105,7 @@ Path ''"));
{ {
ConstructorReadonlyFields c1 = new ConstructorReadonlyFields("String!", int.MaxValue); ConstructorReadonlyFields c1 = new ConstructorReadonlyFields("String!", int.MaxValue);
string json = JsonConvert.SerializeObject(c1, Formatting.Indented); string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""A"": ""String!"", ""A"": ""String!"",
""B"": 2147483647 ""B"": 2147483647
}", json); }", json);
@@ -3126,7 +3128,7 @@ Path ''"));
string json = JsonConvert.SerializeObject(structTest, Formatting.Indented); string json = JsonConvert.SerializeObject(structTest, Formatting.Indented);
Console.WriteLine(json); Console.WriteLine(json);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""StringField"": ""StringField"", ""StringField"": ""StringField"",
""IntField"": 10, ""IntField"": 10,
""StringProperty"": ""StringProperty!"", ""StringProperty"": ""StringProperty!"",
@@ -3149,7 +3151,7 @@ Path ''"));
f.Bars.Add(new Bar { Id = 2 }); f.Bars.Add(new Bar { Id = 2 });
string json = JsonConvert.SerializeObject(f, Formatting.Indented); string json = JsonConvert.SerializeObject(f, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Bars"": [ ""Bars"": [
0, 0,
1, 1,
@@ -3172,7 +3174,7 @@ Path ''"));
dictionary.Add(new Guid("C2594C02-EBA1-426A-AA87-8DD8871350B0"), 2); dictionary.Add(new Guid("C2594C02-EBA1-426A-AA87-8DD8871350B0"), 2);
string json = JsonConvert.SerializeObject(dictionary, Formatting.Indented); string json = JsonConvert.SerializeObject(dictionary, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""f60eaee0-ae47-488e-b330-59527b742d77"": 1, ""f60eaee0-ae47-488e-b330-59527b742d77"": 1,
""c2594c02-eba1-426a-aa87-8dd8871350b0"": 2 ""c2594c02-eba1-426a-aa87-8dd8871350b0"": 2
}", json); }", json);
@@ -3187,7 +3189,7 @@ Path ''"));
string json = JsonConvert.SerializeObject(dictionary, Formatting.Indented); string json = JsonConvert.SerializeObject(dictionary, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Newtonsoft.Json.Tests.TestObjects.Person"": 1, ""Newtonsoft.Json.Tests.TestObjects.Person"": 1,
""Newtonsoft.Json.Tests.TestObjects.Person"": 2 ""Newtonsoft.Json.Tests.TestObjects.Person"": 2
}", json); }", json);
@@ -3307,7 +3309,7 @@ Path ''"));
wagePerson.Name = "Jim Bob"; wagePerson.Name = "Jim Bob";
string json = JsonConvert.SerializeObject(personPropertyClass, Formatting.Indented); string json = JsonConvert.SerializeObject(personPropertyClass, Formatting.Indented);
Assert.AreEqual( StringAssert.AreEqual(
@"{ @"{
""Person"": { ""Person"": {
""HourlyWage"": 12.50, ""HourlyWage"": 12.50,
@@ -3430,7 +3432,7 @@ Path ''"));
string json = g.ToJson(); string json = g.ToJson();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""MyProperty"": ""some value"", ""MyProperty"": ""some value"",
""TheItems"": [ ""TheItems"": [
{ {
@@ -3541,7 +3543,7 @@ Path ''"));
B value = new B(); B value = new B();
string json = JsonConvert.SerializeObject(value, Formatting.Indented); string json = JsonConvert.SerializeObject(value, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""B2"": null, ""B2"": null,
""A1"": null, ""A1"": null,
""B3"": 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); ISerializableTestObject o = new ISerializableTestObject("String!", int.MinValue, dateTimeOffset, person);
string json = JsonConvert.SerializeObject(o, Formatting.Indented); string json = JsonConvert.SerializeObject(o, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""stringValue"": ""String!"", ""stringValue"": ""String!"",
""intValue"": -2147483648, ""intValue"": -2147483648,
""dateTimeOffsetValue"": """ + dateTimeOffsetText + @""", ""dateTimeOffsetValue"": """ + dateTimeOffsetText + @""",
@@ -3986,7 +3988,7 @@ To fix this error either change the environment to be fully trusted, change the
{ {
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""stringValue"": ""String!"", ""stringValue"": ""String!"",
""intValue"": -2147483648, ""intValue"": -2147483648,
""dateTimeOffsetValue"": """ + dateTimeOffsetText + @""", ""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); AA myA = new AA(2);
string json = JsonConvert.SerializeObject(myA, Formatting.Indented); string json = JsonConvert.SerializeObject(myA, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""AA_field1"": 2, ""AA_field1"": 2,
""AA_property1"": 2, ""AA_property1"": 2,
""AA_property2"": 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); BB myB = new BB(3, 4);
json = JsonConvert.SerializeObject(myB, Formatting.Indented); json = JsonConvert.SerializeObject(myB, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""BB_field1"": 4, ""BB_field1"": 4,
""BB_field2"": 4, ""BB_field2"": 4,
""AA_field1"": 3, ""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); XNodeTestObject newTestObject = JsonConvert.DeserializeObject<XNodeTestObject>(json);
Assert.AreEqual(testObject.Document.ToString(), newTestObject.Document.ToString()); 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"" ""root"": ""hehe, root""
} }
}"; }";
Assert.AreEqual(expected, json); StringAssert.AreEqual(expected, json);
XmlNodeTestObject newTestObject = JsonConvert.DeserializeObject<XmlNodeTestObject>(json); XmlNodeTestObject newTestObject = JsonConvert.DeserializeObject<XmlNodeTestObject>(json);
Assert.AreEqual(testObject.Document.InnerXml, newTestObject.Document.InnerXml); 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); string json = JsonConvert.SerializeObject(dictionary, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""First!"": ""First"", ""First!"": ""First"",
""Second!"": ""Second"" ""Second!"": ""Second""
}", json); }", 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); string jsonText = JsonConvert.SerializeObject(new double?[] { 2.4, 4.3, null }, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
2.4, 2.4,
4.3, 4.3,
null null
@@ -4560,7 +4562,7 @@ To fix this error either change the environment to be fully trusted, change the
"III" "III"
}, Formatting.Indented); }, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""One"", ""One"",
""2"", ""2"",
""III"" ""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); string json = JsonConvert.SerializeObject(testStruct, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""MyInt"": 2147483647 ""MyInt"": 2147483647
}", json); }", 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); string json = JsonConvert.SerializeObject(new DerivedEvent(), Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""event"": ""derived"" ""event"": ""derived""
}", json); }", 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); expando.Complex.DateTime = new DateTime(2000, 12, 20, 18, 55, 0, DateTimeKind.Utc);
string json = JsonConvert.SerializeObject(expando, Formatting.Indented); string json = JsonConvert.SerializeObject(expando, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Int"": 1, ""Int"": 1,
""Decimal"": 99.9, ""Decimal"": 99.9,
""Complex"": { ""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); string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Enumerable"": [ ""Enumerable"": [
""One"", ""One"",
""Two"", ""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); string json = JsonConvert.SerializeObject(i, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": null ""Name"": null
}", json); }", 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); string result = JsonConvert.SerializeObject(cc, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""virtualMember"": ""2010-12-31T00:00:00Z"", ""virtualMember"": ""2010-12-31T00:00:00Z"",
""newMemberWithProperty"": null ""newMemberWithProperty"": null
}", result); }", result);
@@ -5390,7 +5392,7 @@ To fix this error either change the environment to be fully trusted, change the
c1.Categories.Add("two"); c1.Categories.Add("two");
string json = JsonConvert.SerializeObject(c1, Formatting.Indented); string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Title"": ""blah"", ""Title"": ""blah"",
""Categories"": [ ""Categories"": [
""one"", ""one"",
@@ -5425,7 +5427,7 @@ To fix this error either change the environment to be fully trusted, change the
c1.Categories.Add("two", 2); c1.Categories.Add("two", 2);
string json = JsonConvert.SerializeObject(c1, Formatting.Indented); string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Title"": ""blah"", ""Title"": ""blah"",
""Categories"": { ""Categories"": {
""one"": 1, ""one"": 1,
@@ -5516,7 +5518,7 @@ To fix this error either change the environment to be fully trusted, change the
NonSerialized = "NonSerialized!" NonSerialized = "NonSerialized!"
}, Formatting.Indented); }, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""DerivedClassValue"": ""DerivedClassValue!"", ""DerivedClassValue"": ""DerivedClassValue!"",
""BaseClassValue"": ""BaseClassValue!"" ""BaseClassValue"": ""BaseClassValue!""
}", json); }", json);
@@ -5527,7 +5529,7 @@ To fix this error either change the environment to be fully trusted, change the
CollectionDerivedClassValue = "CollectionDerivedClassValue!" CollectionDerivedClassValue = "CollectionDerivedClassValue!"
}, Formatting.Indented); }, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""CollectionDerivedClassValue"": ""CollectionDerivedClassValue!"", ""CollectionDerivedClassValue"": ""CollectionDerivedClassValue!"",
""BaseClassValue"": ""BaseClassValue!"" ""BaseClassValue"": ""BaseClassValue!""
}", json); }", 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!"); PrivateMembersClassWithAttributes c1 = new PrivateMembersClassWithAttributes("privateString!", "internalString!", "readonlyString!");
string json = JsonConvert.SerializeObject(c1, Formatting.Indented); string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""_privateString"": ""privateString!"", ""_privateString"": ""privateString!"",
""_readonlyString"": ""readonlyString!"", ""_readonlyString"": ""readonlyString!"",
""_internalString"": ""internalString!"" ""_internalString"": ""internalString!""
@@ -5635,7 +5637,7 @@ To fix this error either change the environment to be fully trusted, change the
DerivedType d = new DerivedType(); DerivedType d = new DerivedType();
string json = JsonConvert.SerializeObject(d, Formatting.Indented); string json = JsonConvert.SerializeObject(d, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""dinosaur"": null, ""dinosaur"": null,
""dog"": null, ""dog"": null,
""cat"": 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(); UriGuidTimeSpanTestClass c1 = new UriGuidTimeSpanTestClass();
string json = JsonConvert.SerializeObject(c1, Formatting.Indented); string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Guid"": ""00000000-0000-0000-0000-000000000000"", ""Guid"": ""00000000-0000-0000-0000-000000000000"",
""NullableGuid"": null, ""NullableGuid"": null,
""TimeSpan"": ""00:00:00"", ""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); string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Guid"": ""1924129c-f7e0-40f3-9607-9939c531395a"", ""Guid"": ""1924129c-f7e0-40f3-9607-9939c531395a"",
""NullableGuid"": ""9e9f3adf-e017-4f72-91e0-617ebe85967d"", ""NullableGuid"": ""9e9f3adf-e017-4f72-91e0-617ebe85967d"",
""TimeSpan"": ""1.00:00:00"", ""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 ContractResolver = contractResolver
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""x"": 2147483647, ""x"": 2147483647,
""y"": 2, ""y"": 2,
""z"": 3 ""z"": 3
@@ -5864,7 +5866,7 @@ To fix this error either change the environment to be fully trusted, change the
ContractResolver = contractResolver ContractResolver = contractResolver
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""x"": 2147483647, ""x"": 2147483647,
""y"": 2, ""y"": 2,
""z"": 3 ""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); string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Integer"": 1, ""Integer"": 1,
""NullableInteger1"": 2, ""NullableInteger1"": 2,
""NullableInteger2"": null ""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); string jsonString = JsonConvert.SerializeObject(expected, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""SourceTypeID"": ""d8220a4b-75b1-4b7a-8112-b7bdae956a45"", ""SourceTypeID"": ""d8220a4b-75b1-4b7a-8112-b7bdae956a45"",
""BrokerID"": ""951663c4-924e-4c86-a57a-7ed737501dbd"", ""BrokerID"": ""951663c4-924e-4c86-a57a-7ed737501dbd"",
""Latitude"": 33.657145, ""Latitude"": 33.657145,
@@ -6363,7 +6365,7 @@ To fix this error either change the environment to be fully trusted, change the
Converters = { new MetroStringConverter() }, Converters = { new MetroStringConverter() },
Formatting = Formatting.Indented Formatting = Formatting.Indented
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
"":::NAME:::"": "":::APPLE:::"", "":::NAME:::"": "":::APPLE:::"",
"":::EXPIRYDATE:::"": ""2012-04-01T00:00:00"", "":::EXPIRYDATE:::"": ""2012-04-01T00:00:00"",
"":::PRICE:::"": 3.99, "":::PRICE:::"": 3.99,
@@ -6389,7 +6391,7 @@ To fix this error either change the environment to be fully trusted, change the
Formatting = Formatting.Indented Formatting = Formatting.Indented
}); });
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
"":::GRAY:::"", "":::GRAY:::"",
"":::GRAY:::"", "":::GRAY:::"",
"":::GRAY:::"", "":::GRAY:::"",
@@ -6542,7 +6544,7 @@ To fix this error either change the environment to be fully trusted, change the
Formatting = Formatting.Indented Formatting = Formatting.Indented
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""DefaultProperty"": null, ""DefaultProperty"": null,
""AllowNullProperty"": null ""AllowNullProperty"": null
}", json); }", 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); string json = JsonConvert.SerializeObject(dic1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""2000-12-12T12:12:12+00:00"": 1, ""2000-12-12T12:12:12+00:00"": 1,
""2013-12-12T12:12:12+00:00"": 2 ""2013-12-12T12:12:12+00:00"": 2
}", json); }", json);
@@ -6631,7 +6633,7 @@ To fix this error either change the environment to be fully trusted, change the
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""\/Date(976623132000+0000)\/"": 1, ""\/Date(976623132000+0000)\/"": 1,
""\/Date(1386850332000+0000)\/"": 2 ""\/Date(1386850332000+0000)\/"": 2
}", json); }", 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); string json = JsonConvert.SerializeObject(dic1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""2000-12-12T12:12:12Z"": 1, ""2000-12-12T12:12:12Z"": 1,
""2013-12-12T12:12:12Z"": 2 ""2013-12-12T12:12:12Z"": 2
}", json); }", json);
@@ -6681,7 +6683,7 @@ To fix this error either change the environment to be fully trusted, change the
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""\/Date(976623132000)\/"": 1, ""\/Date(976623132000)\/"": 1,
""\/Date(1386850332000)\/"": 2 ""\/Date(1386850332000)\/"": 2
}", json); }", 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"", ""EventName"": ""Blackadder III"",
""Venue"": ""Gryphon Theatre"", ""Venue"": ""Gryphon Theatre"",
""Performances"": [ ""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())); //Console.WriteLine(Encoding.UTF8.GetString(ms.ToArray()));
string json = JsonConvert.SerializeObject(dataContract, Formatting.Indented); string json = JsonConvert.SerializeObject(dataContract, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""DataMemberAttribute"": ""Value!"", ""DataMemberAttribute"": ""Value!"",
""IgnoreDataMemberAndDataMemberAttribute"": ""Value!"" ""IgnoreDataMemberAndDataMemberAttribute"": ""Value!""
}", json); }", 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); json = JsonConvert.SerializeObject(poco, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""NoAttribute"": ""Value!"", ""NoAttribute"": ""Value!"",
""DataMemberAttribute"": ""Value!"" ""DataMemberAttribute"": ""Value!""
}", json); }", json);
@@ -6988,7 +6990,7 @@ To fix this error either change the environment to be fully trusted, change the
ContractResolver = new CamelCasePropertyNamesContractResolver() ContractResolver = new CamelCasePropertyNamesContractResolver()
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""key"": 123, ""key"": 123,
""value"": ""test value"" ""value"": ""test value""
}", json); }", json);
@@ -7227,7 +7229,7 @@ To fix this error either change the environment to be fully trusted, change the
FloatFormatHandling = FloatFormatHandling.DefaultValue FloatFormatHandling = FloatFormatHandling.DefaultValue
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Object"": 0.0, ""Object"": 0.0,
""Float"": 0.0, ""Float"": 0.0,
""Double"": 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") Culture = new CultureInfo("en-NZ")
}); });
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""2000 p.m."", ""2000 p.m."",
""2000 p.m."" ""2000 p.m.""
]", json); ]", 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" DateFormatString = @"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffK"
}); });
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""2000-12-12T12:12:12.000Z"", ""2000-12-12T12:12:12.000Z"",
""2000-12-12T12:12:12.000+01:00"" ""2000-12-12T12:12:12.000+01:00""
]", json); ]", json);
@@ -7304,7 +7306,7 @@ To fix this error either change the environment to be fully trusted, change the
string json = sw.ToString(); string json = sw.ToString();
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
""2000 p.m."", ""2000 p.m."",
""2000 p.m."" ""2000 p.m.""
]", json); ]", json);
@@ -7346,7 +7348,7 @@ To fix this error either change the environment to be fully trusted, change the
string json = sw.ToString(); string json = sw.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""html"": ""\u003chtml\u003e\u003c/html\u003e"" ""html"": ""\u003chtml\u003e\u003c/html\u003e""
}", json); }", 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, ""<Active>k__BackingField"": false,
""<Ja>k__BackingField"": false, ""<Ja>k__BackingField"": false,
""<Handlungsbedarf>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); string json = JsonConvert.SerializeObject(new[] { i }, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
123456789999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999990 123456789999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999990
]", json); ]", json);
} }
@@ -7634,7 +7636,7 @@ To fix this error either change the environment to be fully trusted, change the
Formatting = Formatting.Indented Formatting = Formatting.Indented
}); });
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""$id"": ""0b64ffdf-d155-44ad-9689-58d9adb137f3"", ""$id"": ""0b64ffdf-d155-44ad-9689-58d9adb137f3"",
""Name"": ""John Smith"", ""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"); dict2.Add(consoleWriter, "Console");
var text2 = JsonConvert.SerializeObject(dict2, Formatting.Indented, options); var text2 = JsonConvert.SerializeObject(dict2, Formatting.Indented, options);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Console Writer"": ""Console"" ""Console Writer"": ""Console""
}", text2); }", text2);
@@ -7751,7 +7753,7 @@ To fix this error either change the environment to be fully trusted, change the
dict3.Add("Console", consoleWriter); dict3.Add("Console", consoleWriter);
var text3 = JsonConvert.SerializeObject(dict3, Formatting.Indented, options); var text3 = JsonConvert.SerializeObject(dict3, Formatting.Indented, options);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Console"": ""Console Writer"" ""Console"": ""Console Writer""
}", text3); }", 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 c = new TestClassConvertable { Id = new ConvertibleId { Value = 1 }, X = 2 };
var s = JsonConvert.SerializeObject(c, Formatting.Indented); var s = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Id"": ""1"", ""Id"": ""1"",
""X"": 2 ""X"": 2
}", s); }", s);
@@ -8018,7 +8020,7 @@ To fix this error either change the environment to be fully trusted, change the
{ dt, "123" } { dt, "123" }
}, settings); }, settings);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""2000-pie-Dec-Friday-22"": ""123"" ""2000-pie-Dec-Friday-22"": ""123""
}", json); }", json);
@@ -8044,7 +8046,7 @@ To fix this error either change the environment to be fully trusted, change the
{ dt, "123" } { dt, "123" }
}, settings); }, settings);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""2000-pie-Dec-Friday-22"": ""123"" ""2000-pie-Dec-Friday-22"": ""123""
}", json); }", json);
@@ -8070,7 +8072,7 @@ To fix this error either change the environment to be fully trusted, change the
{ dt, "123" } { dt, "123" }
}, settings); }, settings);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""2000-pie-Dec-Friday-22!+00:00"": ""123"" ""2000-pie-Dec-Friday-22!+00:00"": ""123""
}", json); }", json);
@@ -8096,7 +8098,7 @@ To fix this error either change the environment to be fully trusted, change the
{ dt, "123" } { dt, "123" }
}, settings); }, settings);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""2000-pie-Dec-Friday-22!+00:00"": ""123"" ""2000-pie-Dec-Friday-22!+00:00"": ""123""
}", json); }", json);
@@ -151,7 +151,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string jsonString = JsonConvert.SerializeObject(expected, Formatting.Indented); string jsonString = JsonConvert.SerializeObject(expected, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""SourceTypeID"": ""d8220a4b-75b1-4b7a-8112-b7bdae956a45"", ""SourceTypeID"": ""d8220a4b-75b1-4b7a-8112-b7bdae956a45"",
""BrokerID"": ""951663c4-924e-4c86-a57a-7ed737501dbd"", ""BrokerID"": ""951663c4-924e-4c86-a57a-7ed737501dbd"",
""Latitude"": 33.657145, ""Latitude"": 33.657145,
@@ -393,7 +393,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(typeNameProperty, Formatting.Indented); string json = JsonConvert.SerializeObject(typeNameProperty, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""Name!"", ""Name"": ""Name!"",
""Value"": { ""Value"": {
""$type"": """ + listRef + @""", ""$type"": """ + listRef + @""",
@@ -456,7 +456,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c1, Formatting.Indented); string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$id"": ""Id!"", ""$id"": ""Id!"",
""$ref"": ""Ref!"", ""$ref"": ""Ref!"",
""$value"": ""Value!"", ""$value"": ""Value!"",
@@ -110,7 +110,7 @@ namespace Newtonsoft.Json.Tests.Serialization
// "Description": "It's no Bad Boys" // "Description": "It's no Bad Boys"
// } // }
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""Bad Boys III"", ""Name"": ""Bad Boys III"",
""Description"": ""It's no Bad Boys"", ""Description"": ""It's no Bad Boys"",
""Classification"": null, ""Classification"": null,
@@ -119,7 +119,7 @@ namespace Newtonsoft.Json.Tests.Serialization
""ReleaseCountries"": null ""ReleaseCountries"": null
}", included); }", included);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""Bad Boys III"", ""Name"": ""Bad Boys III"",
""Description"": ""It's no Bad Boys"" ""Description"": ""It's no Bad Boys""
}", ignored); }", ignored);
@@ -54,7 +54,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(circularDictionary, Formatting.Indented, string json = JsonConvert.SerializeObject(circularDictionary, Formatting.Indented,
new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All }); new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$id"": ""1"", ""$id"": ""1"",
""other"": { ""other"": {
""$id"": ""2"", ""$id"": ""2"",
@@ -120,7 +120,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Formatting.Indented, Formatting.Indented,
new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
null, null,
[ [
null null
@@ -142,7 +142,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(circularList, Formatting.Indented, string json = JsonConvert.SerializeObject(circularList, Formatting.Indented,
new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All }); new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$id"": ""1"", ""$id"": ""1"",
""$values"": [ ""$values"": [
null, null,
@@ -271,7 +271,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(circularDictionary, Formatting.Indented, string json = JsonConvert.SerializeObject(circularDictionary, Formatting.Indented,
new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""other"": { ""other"": {
""blah"": null ""blah"": null
} }
@@ -354,7 +354,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Converters = new List<JsonConverter> { new CircularReferenceClassConverter() } Converters = new List<JsonConverter> { new CircularReferenceClassConverter() }
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$id"": ""1"", ""$id"": ""1"",
""$type"": ""CircularReferenceClass"", ""$type"": ""CircularReferenceClass"",
""Name"": ""c1"", ""Name"": ""c1"",
@@ -428,7 +428,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}; };
string json = JsonConvert.SerializeObject(employees, Formatting.Indented); string json = JsonConvert.SerializeObject(employees, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""$id"": ""1"", ""$id"": ""1"",
""Name"": ""Mike Manager"", ""Name"": ""Mike Manager"",
@@ -486,7 +486,7 @@ namespace Newtonsoft.Json.Tests.Serialization
PreserveReferencesHandling = PreserveReferencesHandling.Objects PreserveReferencesHandling = PreserveReferencesHandling.Objects
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$id"": ""1"", ""$id"": ""1"",
""Name"": ""c1"", ""Name"": ""c1"",
""Child"": { ""Child"": {
@@ -544,7 +544,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(employees, Formatting.Indented); string json = JsonConvert.SerializeObject(employees, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""$id"": ""1"", ""$id"": ""1"",
""Name"": ""e1"", ""Name"": ""e1"",
@@ -614,7 +614,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(employees, Formatting.Indented); string json = JsonConvert.SerializeObject(employees, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""One"": { ""One"": {
""$id"": ""1"", ""$id"": ""1"",
""Name"": ""e1"", ""Name"": ""e1"",
@@ -841,7 +841,7 @@ namespace Newtonsoft.Json.Tests.Serialization
byte[] data = ms.ToArray(); byte[] data = ms.ToArray();
string json = Encoding.UTF8.GetString(data, 0, data.Length); string json = Encoding.UTF8.GetString(data, 0, data.Length);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$id"": ""1"", ""$id"": ""1"",
""$values"": [ ""$values"": [
{ {
@@ -879,7 +879,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add(3); l.Add(3);
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
1, 1,
2, 2,
3 3
@@ -897,7 +897,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add(c1); l.Add(c1);
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""$id"": ""1"", ""$id"": ""1"",
""MyProperty"": 0 ""MyProperty"": 0
@@ -921,7 +921,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add("Third", 3); l.Add("Third", 3);
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""First"": 1, ""First"": 1,
""Second"": 2, ""Second"": 2,
""Third"": 3 ""Third"": 3
@@ -939,7 +939,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add("Third", c1); l.Add("Third", c1);
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""First"": { ""First"": {
""$id"": ""1"", ""$id"": ""1"",
""MyProperty"": 0 ""MyProperty"": 0
@@ -984,7 +984,7 @@ namespace Newtonsoft.Json.Tests.Serialization
""String"": ""String!"", ""String"": ""String!"",
""Integer"": 2147483647 ""Integer"": 2147483647
}"; }";
Assert.AreEqual(expected, json); StringAssert.AreEqual(expected, json);
ReferenceObject referenceObject = JsonConvert.DeserializeObject<ReferenceObject>(json); ReferenceObject referenceObject = JsonConvert.DeserializeObject<ReferenceObject>(json);
Assert.IsNotNull(referenceObject); Assert.IsNotNull(referenceObject);
@@ -1011,7 +1011,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}; };
string json = JsonConvert.SerializeObject(o1, Formatting.Indented); string json = JsonConvert.SerializeObject(o1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Data"": { ""Data"": {
""Prop1"": { ""Prop1"": {
""$id"": ""1"", ""$id"": ""1"",
@@ -78,7 +78,7 @@ namespace Newtonsoft.Json.Tests.Serialization
{ {
ReferenceLoopHandling = ReferenceLoopHandling.Serialize ReferenceLoopHandling = ReferenceLoopHandling.Serialize
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Value"": { ""Value"": {
""Value"": { ""Value"": {
""Value"": { ""Value"": {
@@ -128,7 +128,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c, Formatting.Indented); string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Text"": ""Text!"", ""Text"": ""Text!"",
""Data"": [ ""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); string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""Member"": ""Value1"", ""Member"": ""Value1"",
""ThrowError"": ""Handle this!"", ""ThrowError"": ""Handle this!"",
@@ -373,7 +373,7 @@ namespace Newtonsoft.Json.Tests.Serialization
// "Title": "Mister Manager" // "Title": "Mister Manager"
//} //}
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""George Michael Bluth"", ""Name"": ""George Michael Bluth"",
""Age"": 16, ""Age"": 16,
""Title"": ""Mister Manager"" ""Title"": ""Mister Manager""
@@ -68,7 +68,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(null, obj.Member5); Assert.AreEqual(null, obj.Member5);
string json = JsonConvert.SerializeObject(obj, Formatting.Indented); string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Member1"": 11, ""Member1"": 11,
""Member2"": ""This value went into the data file during serialization."", ""Member2"": ""This value went into the data file during serialization."",
""Member4"": null ""Member4"": null
@@ -115,7 +115,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(null, obj.Member4); Assert.AreEqual(null, obj.Member4);
string json = JsonConvert.SerializeObject(obj, Formatting.Indented); string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Member1"": 11, ""Member1"": 11,
""Member2"": ""This value went into the data file during serialization."", ""Member2"": ""This value went into the data file during serialization."",
""Member4"": null ""Member4"": null
@@ -151,7 +151,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(null, obj.Member4); Assert.AreEqual(null, obj.Member4);
string json = JsonConvert.SerializeObject(obj, Formatting.Indented); string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
-1.0, -1.0,
1.1, 1.1,
2.222222222, 2.222222222,
@@ -189,7 +189,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(null, obj.Member4); Assert.AreEqual(null, obj.Member4);
string json = JsonConvert.SerializeObject(obj, Formatting.Indented); string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""1.1"": ""first"", ""1.1"": ""first"",
""2.222222222"": ""second"", ""2.222222222"": ""second"",
""2147483647"": ""third"", ""2147483647"": ""third"",
@@ -277,7 +277,7 @@ namespace Newtonsoft.Json.Tests.Serialization
SerializationEventContextSubClassTestObject obj = new SerializationEventContextSubClassTestObject(); SerializationEventContextSubClassTestObject obj = new SerializationEventContextSubClassTestObject();
string json = JsonConvert.SerializeObject(obj, Formatting.Indented); string json = JsonConvert.SerializeObject(obj, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""TestMember"": ""Set!"" ""TestMember"": ""Set!""
}", json); }", json);
} }
@@ -307,7 +307,7 @@ namespace Newtonsoft.Json.Tests.Serialization
"ContextValue") "ContextValue")
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""TestMember"": ""Remoting ContextValue"" ""TestMember"": ""Remoting ContextValue""
}", json); }", json);
} }
@@ -367,7 +367,7 @@ namespace Newtonsoft.Json.Tests.Serialization
IList<string> e = c.GetEvents(); IList<string> e = c.GetEvents();
Assert.AreEqual(@"OnDeserializing StringAssert.AreEqual(@"OnDeserializing
OnDeserializing_Derived OnDeserializing_Derived
OnDeserialized OnDeserialized
OnDeserialized_Derived OnDeserialized_Derived
@@ -386,7 +386,7 @@ OnSerialized_Derived", string.Join(Environment.NewLine, e.ToArray()));
IList<string> e = c.GetEvents(); IList<string> e = c.GetEvents();
Assert.AreEqual(@"OnDeserializing StringAssert.AreEqual(@"OnDeserializing
OnDeserializing_Derived OnDeserializing_Derived
OnDeserializing_Derived_Derived OnDeserializing_Derived_Derived
OnDeserialized OnDeserialized
@@ -415,7 +415,7 @@ OnSerialized_Derived_Derived", string.Join(Environment.NewLine, e.ToArray()));
IList<string> e = c.GetEvents(); IList<string> e = c.GetEvents();
Assert.AreEqual(@"OnDeserializing StringAssert.AreEqual(@"OnDeserializing
OnDeserializing_Derived OnDeserializing_Derived
OnDeserializing_Derived_Derived OnDeserializing_Derived_Derived
OnDeserialized OnDeserialized
@@ -145,14 +145,14 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c, Formatting.Indented); string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Age"": 27 ""Age"": 27
}", json); }", json);
c._shouldSerializeName = true; c._shouldSerializeName = true;
json = JsonConvert.SerializeObject(c, Formatting.Indented); json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""James"", ""Name"": ""James"",
""Age"": 27 ""Age"": 27
}", json); }", json);
@@ -199,7 +199,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(c, Formatting.Indented); string json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Age"": 27 ""Age"": 27
}", json); }", json);
@@ -217,7 +217,7 @@ namespace Newtonsoft.Json.Tests.Serialization
c.FavoriteNumber = 23; c.FavoriteNumber = 23;
json = JsonConvert.SerializeObject(c, Formatting.Indented); json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""James"", ""Name"": ""James"",
""Age"": 27, ""Age"": 27,
""Weight"": 0, ""Weight"": 0,
@@ -356,7 +356,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(joe, Formatting.Indented); string json = JsonConvert.SerializeObject(joe, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Age"": 100, ""Age"": 100,
""Name"": ""Joe Employee"", ""Name"": ""Joe Employee"",
""Manager"": { ""Manager"": {
@@ -58,7 +58,7 @@ namespace Newtonsoft.Json.Tests.Serialization
traceWriter.Trace(TraceLevel.Error, "Error!", null); traceWriter.Trace(TraceLevel.Error, "Error!", null);
traceWriter.Trace(TraceLevel.Off, "Off!", 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 Information: 0 : Info!
Newtonsoft.Json Warning: 0 : Warning! Newtonsoft.Json Warning: 0 : Warning!
Newtonsoft.Json Error: 0 : Error! 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)); Assert.IsTrue(output.Contains(json));
} }
@@ -167,6 +170,9 @@ Newtonsoft.Json Error: 0 : Error!
Assert.AreEqual(1059, output.Length); Assert.AreEqual(1059, output.Length);
Assert.AreEqual(7, memoryTraceWriter.GetTraceMessages().Count()); Assert.AreEqual(7, memoryTraceWriter.GetTraceMessages().Count());
json = StringAssert.Normalize(json);
output = StringAssert.Normalize(output);
Assert.IsTrue(output.Contains(json)); 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("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("Finished serializing Newtonsoft.Json.Tests.Serialization.SpecifiedTestClass. Path ''.", traceWriter.TraceRecords[5].Message);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Age"": 27 ""Age"": 27
}", json); }", json);
@@ -772,7 +778,7 @@ Newtonsoft.Json Error: 0 : Error!
c.FavoriteNumber = 23; c.FavoriteNumber = 23;
json = JsonConvert.SerializeObject(c, Formatting.Indented); json = JsonConvert.SerializeObject(c, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""James"", ""Name"": ""James"",
""Age"": 27, ""Age"": 27,
""Weight"": 0, ""Weight"": 0,
@@ -870,7 +876,7 @@ Newtonsoft.Json Error: 0 : Error!
Console.WriteLine(traceWriter.GetJson()); Console.WriteLine(traceWriter.GetJson());
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Array"": [ ""Array"": [
""String!"", ""String!"",
""2000-12-12T12:12:12Z"", ""2000-12-12T12:12:12Z"",
@@ -1031,7 +1037,7 @@ Newtonsoft.Json Error: 0 : Error!
Console.WriteLine(traceReader.GetJson()); Console.WriteLine(traceReader.GetJson());
Assert.AreEqual(json, traceReader.GetJson()); StringAssert.AreEqual(json, traceReader.GetJson());
} }
#endif #endif
} }
@@ -67,7 +67,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameHandling = TypeNameHandling.Auto TypeNameHandling = TypeNameHandling.Auto
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""movie"": { ""movie"": {
""$type"": ""Newtonsoft.Json.Tests.TestObjects.Movie, Newtonsoft.Json.Tests"", ""$type"": ""Newtonsoft.Json.Tests.TestObjects.Movie, Newtonsoft.Json.Tests"",
""Name"": ""Die Hard"", ""Name"": ""Die Hard"",
@@ -93,7 +93,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameHandling = TypeNameHandling.Auto TypeNameHandling = TypeNameHandling.Auto
}); });
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""Key"": ""movie"", ""Key"": ""movie"",
""Value"": { ""Value"": {
@@ -138,7 +138,7 @@ namespace Newtonsoft.Json.Tests.Serialization
serializer.Serialize(new JsonTextWriter(sw) { Formatting = Formatting.Indented }, new WagePerson(), typeof(Person)); serializer.Serialize(new JsonTextWriter(sw) { Formatting = Formatting.Indented }, new WagePerson(), typeof(Person));
var result = sw.ToString(); var result = sw.ToString();
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$type"": ""Newtonsoft.Json.Tests.TestObjects.WagePerson, Newtonsoft.Json.Tests"", ""$type"": ""Newtonsoft.Json.Tests.TestObjects.WagePerson, Newtonsoft.Json.Tests"",
""HourlyWage"": 0.0, ""HourlyWage"": 0.0,
""Name"": null, ""Name"": null,
@@ -163,7 +163,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameHandling = TypeNameHandling.Auto TypeNameHandling = TypeNameHandling.Auto
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$type"": ""Newtonsoft.Json.Tests.TestObjects.WagePerson, Newtonsoft.Json.Tests"", ""$type"": ""Newtonsoft.Json.Tests.TestObjects.WagePerson, Newtonsoft.Json.Tests"",
""HourlyWage"": 0.0, ""HourlyWage"": 0.0,
""Name"": null, ""Name"": null,
@@ -196,7 +196,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameHandling = TypeNameHandling.Auto TypeNameHandling = TypeNameHandling.Auto
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Array"": [ ""Array"": [
{ {
""$id"": ""1"", ""$id"": ""1"",
@@ -230,7 +230,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameHandling = TypeNameHandling.Objects TypeNameHandling = TypeNameHandling.Objects
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$id"": ""1"", ""$id"": ""1"",
""$type"": """ + employeeRef + @""", ""$type"": """ + employeeRef + @""",
""Name"": null, ""Name"": null,
@@ -308,7 +308,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameAssemblyFormat = FormatterAssemblyStyle.Full TypeNameAssemblyFormat = FormatterAssemblyStyle.Full
}); });
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""$id"": ""1"", ""$id"": ""1"",
""$type"": """ + employeeRef + @""", ""$type"": """ + employeeRef + @""",
@@ -422,7 +422,7 @@ namespace Newtonsoft.Json.Tests.Serialization
JObject o = (JObject)JsonConvert.DeserializeObject(json); JObject o = (JObject)JsonConvert.DeserializeObject(json);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""Name!"", ""Name"": ""Name!"",
""Manager"": null ""Manager"": null
}", o.ToString()); }", o.ToString());
@@ -523,7 +523,7 @@ namespace Newtonsoft.Json.Tests.Serialization
TypeNameAssemblyFormat = FormatterAssemblyStyle.Full TypeNameAssemblyFormat = FormatterAssemblyStyle.Full
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$type"": """ + containerTypeName + @""", ""$type"": """ + containerTypeName + @""",
""In"": { ""In"": {
""$type"": """ + productListTypeName + @""", ""$type"": """ + productListTypeName + @""",
@@ -560,7 +560,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(typeNameProperty, Formatting.Indented); string json = JsonConvert.SerializeObject(typeNameProperty, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""Name!"", ""Name"": ""Name!"",
""Value"": { ""Value"": {
""$type"": """ + typeNamePropertyRef + @""", ""$type"": """ + typeNamePropertyRef + @""",
@@ -591,7 +591,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(typeNameProperty, Formatting.Indented); string json = JsonConvert.SerializeObject(typeNameProperty, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Name"": ""Name!"", ""Name"": ""Name!"",
""Value"": { ""Value"": {
""$type"": """ + listRef + @""", ""$type"": """ + listRef + @""",
@@ -688,7 +688,7 @@ namespace Newtonsoft.Json.Tests.Serialization
//] //]
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""$type"": ""Customer"", ""$type"": ""Customer"",
""Name"": ""Caroline 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); StringReader sr = new StringReader(json);
@@ -872,7 +872,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string urlStatusTypeName = ReflectionUtils.GetTypeName(typeof(UrlStatus), FormatterAssemblyStyle.Simple, null); 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"", ""$type"": ""System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib"",
""First"": { ""First"": {
""$type"": """ + urlStatusTypeName + @""", ""$type"": """ + urlStatusTypeName + @""",
@@ -927,7 +927,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(products, Formatting.Indented, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }); string json = JsonConvert.SerializeObject(products, Formatting.Indented, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$type"": """ + productClassRef + @""", ""$type"": """ + productClassRef + @""",
""$values"": [] ""$values"": []
}", json); }", json);
@@ -1007,7 +1007,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string carClassRef = ReflectionUtils.GetTypeName(typeof(Car), FormatterAssemblyStyle.Simple, null); string carClassRef = ReflectionUtils.GetTypeName(typeof(Car), FormatterAssemblyStyle.Simple, null);
Assert.AreEqual(output, @"{ StringAssert.AreEqual(output, @"{
""$type"": """ + carClassRef + @""", ""$type"": """ + carClassRef + @""",
""Year"": ""2000-10-05T01:01:01Z"", ""Year"": ""2000-10-05T01:01:01Z"",
""Objects"": { ""Objects"": {
@@ -1103,7 +1103,7 @@ namespace Newtonsoft.Json.Tests.Serialization
} }
}); });
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""$type"": "":::MESSAGE:::, AssemblyName"", ""$type"": "":::MESSAGE:::, AssemblyName"",
""Address"": ""jamesnk@testtown.com"", ""Address"": ""jamesnk@testtown.com"",
""Body"": { ""Body"": {
@@ -1146,7 +1146,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add(3); l.Add(3);
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
1, 1,
2, 2,
3 3
@@ -1169,7 +1169,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add(long.MaxValue); l.Add(long.MaxValue);
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"[ StringAssert.AreEqual(@"[
{ {
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"", ""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
""MyProperty"": 0 ""MyProperty"": 0
@@ -1204,7 +1204,7 @@ namespace Newtonsoft.Json.Tests.Serialization
l.Add("Third", long.MaxValue); l.Add("Third", long.MaxValue);
string json = JsonConvert.SerializeObject(l, Formatting.Indented); string json = JsonConvert.SerializeObject(l, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""First"": { ""First"": {
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"", ""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
""MyProperty"": 1 ""MyProperty"": 1
@@ -1246,7 +1246,7 @@ namespace Newtonsoft.Json.Tests.Serialization
""String"": ""String!"", ""String"": ""String!"",
""Integer"": 2147483647 ""Integer"": 2147483647
}"; }";
Assert.AreEqual(expected, json); StringAssert.AreEqual(expected, json);
TypeNameObject o2 = JsonConvert.DeserializeObject<TypeNameObject>(json); TypeNameObject o2 = JsonConvert.DeserializeObject<TypeNameObject>(json);
Assert.IsNotNull(o2); Assert.IsNotNull(o2);
@@ -1255,7 +1255,7 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(1, ((TestComponentSimple)o2.Object1).MyProperty); Assert.AreEqual(1, ((TestComponentSimple)o2.Object1).MyProperty);
CustomAssert.IsInstanceOfType(typeof(long), o2.Object2); CustomAssert.IsInstanceOfType(typeof(long), o2.Object2);
CustomAssert.IsInstanceOfType(typeof(JObject), o2.ObjectNotHandled); CustomAssert.IsInstanceOfType(typeof(JObject), o2.ObjectNotHandled);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""MyProperty"": 2147483647 ""MyProperty"": 2147483647
}", o2.ObjectNotHandled.ToString()); }", o2.ObjectNotHandled.ToString());
} }
@@ -1272,7 +1272,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}; };
string json = JsonConvert.SerializeObject(c1, Formatting.Indented); string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Data"": [ ""Data"": [
1, 1,
""two"", ""two"",
@@ -1312,7 +1312,7 @@ namespace Newtonsoft.Json.Tests.Serialization
}; };
string json = JsonConvert.SerializeObject(c1, Formatting.Indented); string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Data"": [ ""Data"": [
{ {
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"", ""$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); string json = JsonConvert.SerializeObject(c1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Data"": { ""Data"": {
""one"": { ""one"": {
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"", ""$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); string json = JsonConvert.SerializeObject(o1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Data"": { ""Data"": {
""Prop1"": { ""Prop1"": {
""$type"": ""System.Collections.Generic.List`1[[System.Object, mscorlib]], mscorlib"", ""$type"": ""System.Collections.Generic.List`1[[System.Object, mscorlib]], mscorlib"",
@@ -1522,7 +1522,7 @@ namespace Newtonsoft.Json.Tests.Serialization
d1.Data = (DynamicDictionary)data; d1.Data = (DynamicDictionary)data;
string json = JsonConvert.SerializeObject(d1, Formatting.Indented); string json = JsonConvert.SerializeObject(d1, Formatting.Indented);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""Data"": { ""Data"": {
""one"": { ""one"": {
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"", ""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
@@ -1620,7 +1620,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(p, settings); string json = JsonConvert.SerializeObject(p, settings);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""c"": { ""c"": {
""$type"": ""Newtonsoft.Json.Tests.Serialization.MyChild, Newtonsoft.Json.Tests"", ""$type"": ""Newtonsoft.Json.Tests.Serialization.MyChild, Newtonsoft.Json.Tests"",
""p"": ""string!"" ""p"": ""string!""
@@ -1655,7 +1655,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(p, settings); string json = JsonConvert.SerializeObject(p, settings);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""c"": { ""c"": {
""$type"": ""Newtonsoft.Json.Tests.Serialization.MyChildList, Newtonsoft.Json.Tests"", ""$type"": ""Newtonsoft.Json.Tests.Serialization.MyChildList, Newtonsoft.Json.Tests"",
""$values"": [ ""$values"": [
@@ -1694,7 +1694,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = JsonConvert.SerializeObject(pp, settings); string json = JsonConvert.SerializeObject(pp, settings);
Assert.AreEqual(@"{ StringAssert.AreEqual(@"{
""ParentProp"": { ""ParentProp"": {
""c"": { ""c"": {
""$type"": ""Newtonsoft.Json.Tests.Serialization.MyChild, Newtonsoft.Json.Tests"", ""$type"": ""Newtonsoft.Json.Tests.Serialization.MyChild, Newtonsoft.Json.Tests"",
+32 -6
View File
@@ -184,14 +184,27 @@ namespace Newtonsoft.Json.Tests
public static void AreEqual(string expected, string actual) public static void AreEqual(string expected, string actual)
{ {
if (expected != null) expected = Normalize(expected);
expected = Regex.Replace(expected, "\r\n"); actual = Normalize(actual);
if (actual != null)
actual = Regex.Replace(actual, "\r\n");
Assert.AreEqual(expected, actual); Assert.AreEqual(expected, actual);
} }
public static bool Equals(string s1, string s2)
{
s1 = Normalize(s1);
s2 = Normalize(s2);
return string.Equals(s1, s2);
}
public static string Normalize(string s)
{
if (s != null)
s = Regex.Replace(s, "\r\n");
return s;
}
} }
public static class ExceptionAssert public static class ExceptionAssert
@@ -208,7 +221,20 @@ namespace Newtonsoft.Json.Tests
catch (TException ex) catch (TException ex)
{ {
if (possibleMessages != null && possibleMessages.Length > 0) if (possibleMessages != null && possibleMessages.Length > 0)
CustomAssert.Contains(possibleMessages, ex.Message, "Unexpected exception message." + Environment.NewLine + "Expected one of: " + string.Join(Environment.NewLine, possibleMessages) + Environment.NewLine + "Got: " + ex.Message + Environment.NewLine + Environment.NewLine + ex); {
bool match = false;
foreach (string possibleMessage in possibleMessages)
{
if (StringAssert.Equals(possibleMessage, ex.Message))
{
match = true;
break;
}
}
if (!match)
throw new Exception("Unexpected exception message." + Environment.NewLine + "Expected one of: " + string.Join(Environment.NewLine, possibleMessages) + Environment.NewLine + "Got: " + ex.Message + Environment.NewLine + Environment.NewLine + ex);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -523,9 +523,11 @@ namespace Newtonsoft.Json.Serialization
#endif #endif
} }
throw JsonSerializationException.Create(reader, @"Cannot deserialize the current JSON object (e.g. {{""name"":""value""}}) into type '{0}' because the type requires a {1} to deserialize correctly. string message = @"Cannot deserialize the current JSON object (e.g. {{""name"":""value""}}) into type '{0}' because the type requires a {1} to deserialize correctly." + Environment.NewLine +
To fix this error either change the JSON to a {1} 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. @"To fix this error either change the JSON to a {1} 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;
".FormatWith(CultureInfo.InvariantCulture, resolvedObjectType, GetExpectedDescription(contract))); message = message.FormatWith(CultureInfo.InvariantCulture, resolvedObjectType, GetExpectedDescription(contract));
throw JsonSerializationException.Create(reader, message);
} }
private bool ReadMetadataPropertiesToken(JTokenReader reader, ref Type objectType, ref JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue, out object newValue, out string id) private bool ReadMetadataPropertiesToken(JTokenReader reader, ref Type objectType, ref JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, object existingValue, out object newValue, out string id)
@@ -745,9 +747,13 @@ To fix this error either change the JSON to a {1} or change the deserialized typ
JsonArrayContract arrayContract = contract as JsonArrayContract; JsonArrayContract arrayContract = contract as JsonArrayContract;
if (arrayContract == null) if (arrayContract == null)
throw JsonSerializationException.Create(reader, @"Cannot deserialize the current JSON array (e.g. [1,2,3]) into type '{0}' because the type requires a {1} to deserialize correctly. {
To fix this error either change the JSON to a {1} 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. string message = @"Cannot deserialize the current JSON array (e.g. [1,2,3]) into type '{0}' because the type requires a {1} to deserialize correctly." + Environment.NewLine +
".FormatWith(CultureInfo.InvariantCulture, objectType, GetExpectedDescription(contract))); @"To fix this error either change the JSON to a {1} 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." + Environment.NewLine;
message = message.FormatWith(CultureInfo.InvariantCulture, objectType, GetExpectedDescription(contract));
throw JsonSerializationException.Create(reader, message);
}
return arrayContract; return arrayContract;
} }
@@ -1450,9 +1456,11 @@ To fix this error either change the JSON to a {1} or change the deserialized typ
if (!JsonTypeReflector.FullyTrusted) if (!JsonTypeReflector.FullyTrusted)
{ {
throw JsonSerializationException.Create(reader, @"Type '{0}' implements ISerializable but cannot be deserialized using the ISerializable interface because the current application is not fully trusted and ISerializable can expose secure data. string message = @"Type '{0}' implements ISerializable but cannot be deserialized using the ISerializable interface because the current application is not fully trusted and ISerializable can expose secure data." + Environment.NewLine +
To fix this error either change the environment to be fully trusted, change the application to not deserialize the type, add JsonObjectAttribute to the type or change the JsonSerializer setting ContractResolver to use a new DefaultContractResolver with IgnoreSerializableInterface set to true. @"To fix this error either change the environment to be fully trusted, change the application to not deserialize the type, add JsonObjectAttribute to the type or change the JsonSerializer setting ContractResolver to use a new DefaultContractResolver with IgnoreSerializableInterface set to true." + Environment.NewLine;
".FormatWith(CultureInfo.InvariantCulture, objectType)); message = message.FormatWith(CultureInfo.InvariantCulture, objectType);
throw JsonSerializationException.Create(reader, message);
} }
if (TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Info) if (TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Info)