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