-Replace tests console writes with asserts
This commit is contained in:
@@ -111,16 +111,13 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
IPerson person = people[0];
|
||||
|
||||
Console.WriteLine(person.GetType());
|
||||
// Newtonsoft.Json.Tests.Employee
|
||||
Assert.AreEqual("Newtonsoft.Json.Tests.Employee", person.GetType().Name);
|
||||
|
||||
Console.WriteLine(person.FirstName);
|
||||
// Maurice
|
||||
Assert.AreEqual("Maurice", person.FirstName);
|
||||
|
||||
Employee employee = (Employee)person;
|
||||
|
||||
Console.WriteLine(employee.JobTitle);
|
||||
// Support
|
||||
Assert.AreEqual("Support", employee.JobTitle);
|
||||
}
|
||||
|
||||
public class MyClass
|
||||
|
||||
@@ -109,7 +109,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
ts.Stop();
|
||||
|
||||
Console.WriteLine(ts.Elapsed.TotalSeconds);
|
||||
Console.WriteLine(json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -136,7 +135,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
ts.Stop();
|
||||
|
||||
Console.WriteLine(ts.Elapsed.TotalSeconds);
|
||||
Console.WriteLine(json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -224,10 +222,8 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
object[] fields = caseInfo.FieldReader.Invoke(value);
|
||||
|
||||
foreach (object field in fields)
|
||||
{
|
||||
Console.WriteLine(field);
|
||||
}
|
||||
Assert.AreEqual(10, fields[0]);
|
||||
Assert.AreEqual(5, fields[1]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -242,10 +238,9 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
10.0, 5.0
|
||||
});
|
||||
|
||||
Console.WriteLine(value.ToString());
|
||||
|
||||
Console.WriteLine(value.width);
|
||||
Console.WriteLine(value.length);
|
||||
Assert.AreEqual("Newtonsoft.Json.Tests.TestObjects.Shape+Rectangle", value.ToString());
|
||||
Assert.AreEqual(10, value.width);
|
||||
Assert.AreEqual(5, value.length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -293,8 +288,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
TypeNameHandling = TypeNameHandling.All
|
||||
});
|
||||
|
||||
Console.WriteLine(json);
|
||||
|
||||
Assert.AreEqual(@"{""Case"":""Rectangle"",""Fields"":[10.0,5.0]}", json);
|
||||
|
||||
Shape c = JsonConvert.DeserializeObject<Shape>(json);
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
// "LastModified": "2009-04-12T20:44:55"
|
||||
// }
|
||||
|
||||
Console.WriteLine(jsonText);
|
||||
Assert.AreEqual(@"{""Name"":""Keith"",""BirthDate"":""1980-03-08T00:00:00"",""LastModified"":""2009-04-12T20:44:55""}", jsonText);
|
||||
}
|
||||
|
||||
#if !NET20
|
||||
|
||||
@@ -70,13 +70,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
Assert.AreEqual("new Date(976918263055)", result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void sdfs()
|
||||
{
|
||||
int i = Convert.ToInt32("+1");
|
||||
Console.WriteLine(i);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializeNullableDateTimeClass()
|
||||
{
|
||||
|
||||
@@ -491,15 +491,11 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
Value2 = DuplicateNameEnum2.foo_bar_NOT_USED
|
||||
});
|
||||
|
||||
Console.WriteLine(Encoding.UTF8.GetString(ms.ToArray(), 0, (int)ms.Length));
|
||||
|
||||
string xml = @"<DuplicateEnumNameTestClass xmlns=""http://schemas.datacontract.org/2004/07/Newtonsoft.Json.Tests.Converters"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"">
|
||||
<Value>foo_bar</Value>
|
||||
<Value2>foo_bar</Value2>
|
||||
</DuplicateEnumNameTestClass>";
|
||||
|
||||
Console.WriteLine(xml);
|
||||
|
||||
var o = (DuplicateEnumNameTestClass)s.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(xml)));
|
||||
|
||||
Assert.AreEqual(DuplicateNameEnum.foo_bar, o.Value);
|
||||
|
||||
@@ -151,12 +151,21 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
string json = JsonConvert.SerializeObject(d, Formatting.Indented);
|
||||
|
||||
Console.WriteLine(json);
|
||||
Assert.AreEqual(@"{
|
||||
""result"": {
|
||||
""@xp_0:end"": ""2014-08-15 13:12:11.9184"",
|
||||
""@xp_0:start"": ""2014-08-15 13:11:49.3140"",
|
||||
""@xp_0:time_diff"": ""22604.3836"",
|
||||
""@xmlns:xp_0"": ""Test1"",
|
||||
""@p2:end"": ""2014-08-15 13:13:49.5522"",
|
||||
""@p2:start"": ""2014-08-15 13:13:49.0268"",
|
||||
""@p2:time_diff"": ""525.4646"",
|
||||
""@xmlns:p2"": ""Test2""
|
||||
}
|
||||
}", json);
|
||||
|
||||
XDocument doc = JsonConvert.DeserializeObject<XDocument>(json);
|
||||
|
||||
Console.WriteLine(doc.ToString());
|
||||
|
||||
Assert.AreEqual(xml, doc.ToString());
|
||||
}
|
||||
#endif
|
||||
@@ -171,12 +180,21 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
string json = JsonConvert.SerializeObject(d, Formatting.Indented);
|
||||
|
||||
Console.WriteLine(json);
|
||||
Assert.AreEqual(@"{
|
||||
""result"": {
|
||||
""@xp_0:end"": ""2014-08-15 13:12:11.9184"",
|
||||
""@xp_0:start"": ""2014-08-15 13:11:49.3140"",
|
||||
""@xp_0:time_diff"": ""22604.3836"",
|
||||
""@xmlns:xp_0"": ""Test1"",
|
||||
""@p2:end"": ""2014-08-15 13:13:49.5522"",
|
||||
""@p2:start"": ""2014-08-15 13:13:49.0268"",
|
||||
""@p2:time_diff"": ""525.4646"",
|
||||
""@xmlns:p2"": ""Test2""
|
||||
}
|
||||
}", json);
|
||||
|
||||
XmlDocument doc = JsonConvert.DeserializeObject<XmlDocument>(json);
|
||||
|
||||
Console.WriteLine(doc.OuterXml);
|
||||
|
||||
Assert.AreEqual(xml, doc.OuterXml);
|
||||
}
|
||||
|
||||
@@ -378,7 +396,7 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
{
|
||||
XmlDocument doc = JsonConvert.DeserializeXmlNode("{ A: { '@xsi:nil': true } }");
|
||||
|
||||
Console.WriteLine(doc.OuterXml);
|
||||
Assert.AreEqual(@"<A nil=""true"" />", doc.OuterXml);
|
||||
|
||||
XDocument xdoc = JsonConvert.DeserializeXNode("{ A: { '@xsi:nil': true } }");
|
||||
|
||||
@@ -468,10 +486,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
}";
|
||||
|
||||
StringAssert.AreEqual(expected, jsonText);
|
||||
|
||||
Console.WriteLine("DocumentSerializeIndented");
|
||||
Console.WriteLine(jsonText);
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -480,8 +494,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
XmlDocument doc = new XmlDocument();
|
||||
string jsonText;
|
||||
|
||||
Console.WriteLine("SerializeNodeTypes");
|
||||
|
||||
string xml = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
|
||||
<xs:schema xs:id=""SomeID""
|
||||
xmlns=""""
|
||||
@@ -500,7 +512,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
jsonText = JsonConvert.SerializeXmlNode(attribute);
|
||||
|
||||
Console.WriteLine(jsonText);
|
||||
Assert.AreEqual(@"{""@msdata:IsDataSet"":""true""}", jsonText);
|
||||
|
||||
#if !NET20
|
||||
@@ -517,7 +528,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
jsonText = JsonConvert.SerializeXmlNode(instruction);
|
||||
|
||||
Console.WriteLine(jsonText);
|
||||
Assert.AreEqual(@"{""?xml-stylesheet"":""href=\""classic.xsl\"" type=\""text/xml\""""}", jsonText);
|
||||
|
||||
|
||||
@@ -526,7 +536,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
jsonText = JsonConvert.SerializeXmlNode(cDataSection);
|
||||
|
||||
Console.WriteLine(jsonText);
|
||||
Assert.AreEqual(@"{""#cdata-section"":""<Kiwi>true</Kiwi>""}", jsonText);
|
||||
|
||||
|
||||
@@ -574,10 +583,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
string expected = @"{""Item"":[""widget"",""widget""]}";
|
||||
|
||||
Assert.AreEqual(expected, jsonText);
|
||||
|
||||
Console.WriteLine("DocumentFragmentSerialize");
|
||||
Console.WriteLine(jsonText);
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -794,11 +799,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
XmlDocument deserializedDoc = (XmlDocument)DeserializeXmlNode(jsonText);
|
||||
|
||||
Assert.AreEqual(doc.InnerXml, deserializedDoc.InnerXml);
|
||||
|
||||
Console.WriteLine("NamespaceSerializeDeserialize");
|
||||
Console.WriteLine(jsonText);
|
||||
Console.WriteLine(deserializedDoc.InnerXml);
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -834,10 +834,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
string formattedXml = GetIndentedInnerXml(doc);
|
||||
|
||||
Console.WriteLine("DocumentDeserialize");
|
||||
Console.WriteLine(formattedXml);
|
||||
Console.WriteLine();
|
||||
|
||||
StringAssert.AreEqual(expected, formattedXml);
|
||||
}
|
||||
|
||||
@@ -901,7 +897,26 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
|
||||
string jsonText = SerializeXmlNode(doc);
|
||||
|
||||
Console.WriteLine(jsonText);
|
||||
Assert.AreEqual(@"{
|
||||
""?xml"": {
|
||||
""@version"": ""1.0"",
|
||||
""@standalone"": ""no""
|
||||
},
|
||||
""root"": {
|
||||
""person"": [
|
||||
{
|
||||
""@id"": ""1"",
|
||||
""name"": ""Alan"",
|
||||
""url"": null
|
||||
},
|
||||
{
|
||||
""@id"": ""2"",
|
||||
""name"": ""Louis"",
|
||||
""url"": ""http://www.yahoo.com""
|
||||
}
|
||||
]
|
||||
}
|
||||
}", jsonText);
|
||||
|
||||
XmlDocument newDoc = (XmlDocument)DeserializeXmlNode(jsonText);
|
||||
|
||||
@@ -1171,8 +1186,6 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
#if !NET20
|
||||
XDocument newXDoc = JsonConvert.DeserializeXNode(json, "myRoot", true);
|
||||
|
||||
Console.WriteLine(IndentXml(newXDoc.ToString(SaveOptions.DisableFormatting)));
|
||||
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user