-Updated NuGet packages

-Fixed xunit warnings
This commit is contained in:
James Newton-King
2017-11-26 13:00:07 +13:00
parent df3c1caef2
commit 2c9d9b9598
11 changed files with 87 additions and 125 deletions
@@ -75,6 +75,7 @@ namespace Newtonsoft.Json.Tests.Documentation
[TestFixture]
public class LinqToJsonTests : TestFixtureBase
{
[Test]
public void LinqToJsonBasic()
{
#region LinqToJsonBasic
@@ -98,6 +99,7 @@ namespace Newtonsoft.Json.Tests.Documentation
#endregion
}
[Test]
public void LinqToJsonCreateNormal()
{
#region LinqToJsonCreateNormal
@@ -105,7 +105,14 @@ namespace Newtonsoft.Json.Tests.Documentation
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
return null;
JObject o = (JObject)JToken.ReadFrom(reader);
Person p = new Person
{
Name = (string)o["Name"]
};
return p;
}
public override bool CanConvert(Type objectType)
@@ -127,37 +134,6 @@ namespace Newtonsoft.Json.Tests.Documentation
Console.WriteLine(json);
}
public void DeserializeString()
{
#region DeserializeString
HttpClient client = new HttpClient();
// read the json into a string
// string could potentially be very large and cause memory problems
string json = client.GetStringAsync("http://www.test.com/large.json").Result;
Person p = JsonConvert.DeserializeObject<Person>(json);
#endregion
}
public void DeserializeStream()
{
#region DeserializeStream
HttpClient client = new HttpClient();
using (Stream s = client.GetStreamAsync("http://www.test.com/large.json").Result)
using (StreamReader sr = new StreamReader(s))
using (JsonReader reader = new JsonTextReader(sr))
{
JsonSerializer serializer = new JsonSerializer();
// read the json from a stream
// json size doesn't matter because only a small piece is read at a time from the HTTP request
Person p = serializer.Deserialize<Person>(reader);
}
#endregion
}
}
public static class PersonWriter
@@ -52,6 +52,7 @@ namespace Newtonsoft.Json.Tests.Documentation
[TestFixture]
public class ReadingAndWritingJsonTests : TestFixtureBase
{
[Test]
public void ReadingAndWritingJsonText()
{
#region ReadingAndWritingJsonText
@@ -134,6 +135,7 @@ namespace Newtonsoft.Json.Tests.Documentation
#endregion
}
[Test]
public void ReadingAndWritingJsonLinq()
{
#region ReadingAndWritingJsonLinq
@@ -148,6 +150,8 @@ namespace Newtonsoft.Json.Tests.Documentation
Console.WriteLine(p.Name);
// John Smith
#endregion
Assert.AreEqual("John Smith", p.Name);
}
}
}
@@ -46,12 +46,21 @@ using Newtonsoft.Json.Tests.TestObjects;
using Newtonsoft.Json.Utilities;
using System.Globalization;
using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs;
using OriginalStreamWriter = System.IO.StreamWriter;
using StreamWriter = Newtonsoft.Json.Tests.Documentation.SerializationTests.StreamWriter;
namespace Newtonsoft.Json.Tests.Documentation
{
[TestFixture]
public class SerializationTests : TestFixtureBase
{
public class StreamWriter : OriginalStreamWriter
{
public StreamWriter(string path) : base(TestFixtureBase.ResolvePath(Path.GetFileName(path)))
{
}
}
[Test]
public void SerializeObject()
{
@@ -81,6 +90,7 @@ namespace Newtonsoft.Json.Tests.Documentation
Assert.AreEqual("Apple", deserializedProduct.Name);
}
[Test]
public void JsonSerializerToStream()
{
#region JsonSerializerToStream
@@ -114,7 +124,6 @@ namespace Newtonsoft.Json.Tests.Documentation
// new Date(976918263055)
[JsonProperty]
[JsonConverter(typeof(JavaScriptDateTimeConverter))]
public DateTime LastModified { get; set; }
// not serialized because mode is opt-in
@@ -338,6 +347,7 @@ namespace Newtonsoft.Json.Tests.Documentation
}", json);
}
[Test]
public void PreservingObjectReferencesOff()
{
#region PreservingObjectReferencesOff
@@ -679,6 +689,7 @@ namespace Newtonsoft.Json.Tests.Documentation
public DateTime LogDate { get; set; }
}
[Test]
public void WriteJsonDates()
{
LogEntry entry = new LogEntry
@@ -814,6 +825,7 @@ namespace Newtonsoft.Json.Tests.Documentation
}
#endregion
[Test]
public void ReducingSerializedJsonSizeDefaultValueHandlingExample()
{
#region ReducingSerializedJsonSizeDefaultValueHandlingExample
@@ -862,7 +874,7 @@ namespace Newtonsoft.Json.Tests.Documentation
Assert.AreEqual(@"{
""Company"": ""Acme Ltd."",
""Amount"": 50.0
}", included);
}", ignored);
}
#region ReducingSerializedJsonSizeContractResolverObject
@@ -897,6 +909,7 @@ namespace Newtonsoft.Json.Tests.Documentation
}
#endregion
[Test]
public void ReducingSerializedJsonSizeContractResolverExample()
{
#region ReducingSerializedJsonSizeContractResolverExample