-Documentation
This commit is contained in:
James Newton-King
2014-11-30 21:10:54 +13:00
parent b3b5a60bdb
commit 449f4dd841
4 changed files with 57 additions and 2 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
Json.NET implements Json.NET implements
<externalLink> <externalLink>
<linkText>JSON Schema Draft 3</linkText> <linkText>JSON Schema Draft 3</linkText>
<linkUri>http://tools.ietf.org/search/draft-zyp-json-schema-03/</linkUri> <linkUri>https://tools.ietf.org/html/draft-zyp-json-schema-03</linkUri>
<linkTarget>_blank</linkTarget> <linkTarget>_blank</linkTarget>
</externalLink>. </externalLink>.
@@ -54,6 +54,26 @@ namespace Newtonsoft.Json.Tests.Linq
[TestFixture] [TestFixture]
public class LinqToJsonTest : TestFixtureBase public class LinqToJsonTest : TestFixtureBase
{ {
[Test]
public void IncompleteContainers()
{
ExceptionAssert.Throws<JsonReaderException>(
() => JArray.Parse("[1,"),
"Unexpected end of content while loading JArray. Path '[0]', line 1, position 3.");
ExceptionAssert.Throws<JsonReaderException>(
() => JArray.Parse("[1"),
"Unexpected end of content while loading JArray. Path '[0]', line 1, position 2.");
ExceptionAssert.Throws<JsonReaderException>(
() => JObject.Parse("{'key':1,"),
"Unexpected end of content while loading JObject. Path 'key', line 1, position 9.");
ExceptionAssert.Throws<JsonReaderException>(
() => JObject.Parse("{'key':1"),
"Unexpected end of content while loading JObject. Path 'key', line 1, position 8.");
}
[Test] [Test]
public void EmptyJEnumerableCount() public void EmptyJEnumerableCount()
{ {
@@ -31,7 +31,9 @@ using System.Security;
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
#if PORTABLE #if PORTABLE40
[assembly: AssemblyTitle("Json.NET Tests Portable .NET 4.0")]
#elif PORTABLE
[assembly: AssemblyTitle("Json.NET Tests Portable")] [assembly: AssemblyTitle("Json.NET Tests Portable")]
#elif NETFX_CORE #elif NETFX_CORE
[assembly: AssemblyTitle("Json.NET Tests WinRT")] [assembly: AssemblyTitle("Json.NET Tests WinRT")]
@@ -95,6 +95,39 @@ namespace Newtonsoft.Json.Tests.Serialization
[TestFixture] [TestFixture]
public class JsonSerializerTest : TestFixtureBase public class JsonSerializerTest : TestFixtureBase
{ {
[Test]
public void IncompleteContainers()
{
ExceptionAssert.Throws<JsonSerializationException>(
() => JsonConvert.DeserializeObject<IList<int>>("[1,"),
"Unexpected end when deserializing array. Path '[0]', line 1, position 3.");
ExceptionAssert.Throws<JsonSerializationException>(
() => JsonConvert.DeserializeObject<IList<int>>("[1"),
"Unexpected end when deserializing array. Path '[0]', line 1, position 2.");
ExceptionAssert.Throws<JsonSerializationException>(
() => JsonConvert.DeserializeObject<IDictionary<string, int>>("{'key':1,"),
"Unexpected end when deserializing object. Path 'key', line 1, position 9.");
ExceptionAssert.Throws<JsonSerializationException>(
() => JsonConvert.DeserializeObject<IDictionary<string, int>>("{'key':1"),
"Unexpected end when deserializing object. Path 'key', line 1, position 8.");
ExceptionAssert.Throws<JsonSerializationException>(
() => JsonConvert.DeserializeObject<IncompleteTestClass>("{'key':1,"),
"Unexpected end when deserializing object. Path 'key', line 1, position 9.");
ExceptionAssert.Throws<JsonSerializationException>(
() => JsonConvert.DeserializeObject<IncompleteTestClass>("{'key':1"),
"Unexpected end when deserializing object. Path 'key', line 1, position 8.");
}
public class IncompleteTestClass
{
public int Key { get; set; }
}
#if !NET20 #if !NET20
public enum EnumA public enum EnumA
{ {