-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]
|
||||
|
||||
Reference in New Issue
Block a user