From 6ce847411a78b61cbf3597a0299b7b4006bcc9c7 Mon Sep 17 00:00:00 2001 From: JamesNK Date: Fri, 3 Feb 2012 02:31:56 +0000 Subject: -Fixed attributes on nullable structs not being used -Fixed deserializing nullable enums -Fixed JsonConstructorAttribute incorrectly being allowed on properties -Added new NUnit --- Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Src/Newtonsoft.Json.Tests/Bson') diff --git a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs index 00ed770..d57e264 100644 --- a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs +++ b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs @@ -263,6 +263,30 @@ namespace Newtonsoft.Json.Tests.Bson Assert.IsFalse(reader.Read()); } + [Test] + [ExpectedException(typeof(JsonReaderException), ExpectedMessage = "Could not convert string to integer: a.")] + public void ReadAsInt32BadString() + { + byte[] data = MiscellaneousUtils.HexToBytes("20-00-00-00-02-30-00-02-00-00-00-61-00-02-31-00-02-00-00-00-62-00-02-32-00-02-00-00-00-63-00-00"); + + MemoryStream ms = new MemoryStream(data); + BsonReader reader = new BsonReader(ms); + + Assert.AreEqual(false, reader.ReadRootValueAsArray); + Assert.AreEqual(DateTimeKind.Local, reader.DateTimeKindHandling); + + reader.ReadRootValueAsArray = true; + reader.DateTimeKindHandling = DateTimeKind.Utc; + + Assert.AreEqual(true, reader.ReadRootValueAsArray); + Assert.AreEqual(DateTimeKind.Utc, reader.DateTimeKindHandling); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(JsonToken.StartArray, reader.TokenType); + + reader.ReadAsInt32(); + } + [Test] public void ReadBytes() { -- cgit v1.2.3