-Fixed null reference error when using JEnumerable created with default constructor

-Tests
This commit is contained in:
James Newton-King
2014-09-25 20:28:47 +12:00
parent b3e667fa78
commit 64ffa098b9
24 changed files with 225382 additions and 15 deletions
@@ -132,6 +132,67 @@ namespace Newtonsoft.Json.Tests
SerializeTests(test);
}
[Test]
public void ReadLargeJson()
{
for (int i = 0; i < 100; i++)
{
using (var fs = System.IO.File.OpenText("large.json"))
using (JsonTextReader jsonTextReader = new JsonTextReader(fs))
{
while (jsonTextReader.Read())
{
}
}
}
}
public class Friend
{
public int id { get; set; }
public string name { get; set; }
}
public class RootObject
{
public string _id { get; set; }
public int index { get; set; }
public Guid guid { get; set; }
public bool isActive { get; set; }
public string balance { get; set; }
public string picture { get; set; }
public int age { get; set; }
public string eyeColor { get; set; }
public string name { get; set; }
public string gender { get; set; }
public string company { get; set; }
public string email { get; set; }
public string phone { get; set; }
public string address { get; set; }
public string about { get; set; }
public string registered { get; set; }
public double latitude { get; set; }
public decimal longitude { get; set; }
public List<string> tags { get; set; }
public List<Friend> friends { get; set; }
public string greeting { get; set; }
public string favoriteFruit { get; set; }
}
[Test]
public void DeserializeLargeJson()
{
for (int i = 0; i < 100; i++)
{
using (var fs = System.IO.File.OpenText("large.json"))
using (JsonTextReader jsonTextReader = new JsonTextReader(fs))
{
JsonSerializer serializer = new JsonSerializer();
serializer.Deserialize<IList<RootObject>>(jsonTextReader);
}
}
}
[Test]
public void SerializeKeyValuePair()
{