-Fixed exception message typo

-Fixed serializer sometimes not using DateParseHandling setting
-Fixed error in JsonWriter.WriteToken when writing a DateTimeOffset
-Fixed error when serializing emitted classes that have a constructor with null named parameters (really?)
This commit is contained in:
James Newton-King
2012-10-02 21:54:10 +13:00
parent 0bf5f27f2f
commit e2a0191ee5
8 changed files with 47 additions and 13 deletions
@@ -1312,7 +1312,7 @@ keyword such as type of business.""
String strFromTest = JsonConvert.SerializeObject(testClass);
ExceptionAssert.Throws<JsonSerializationException>(
@"Could not create an instance of type Newtonsoft.Json.Tests.TestObjects.ICo. Type is an interface or abstract class and cannot be instantated. Path 'co.Name', line 1, position 14.",
@"Could not create an instance of type Newtonsoft.Json.Tests.TestObjects.ICo. Type is an interface or abstract class and cannot be instantiated. Path 'co.Name', line 1, position 14.",
() =>
{
InterfacePropertyTestClass testFromDe = (InterfacePropertyTestClass)JsonConvert.DeserializeObject(strFromTest, typeof(InterfacePropertyTestClass));
@@ -7162,6 +7162,23 @@ Parameter name: value",
}", json);
}
#endif
#if !NET20
[Test]
public void RoundtripOfDateTimeOffset()
{
var content = @"{""startDateTime"":""2012-07-19T14:30:00+09:30""}";
var jsonSerializerSettings = new JsonSerializerSettings() {DateFormatHandling = DateFormatHandling.IsoDateFormat, DateParseHandling = DateParseHandling.DateTimeOffset, DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind};
var obj = (JObject)JsonConvert.DeserializeObject(content, jsonSerializerSettings);
var dateTimeOffset = (DateTimeOffset)((JValue) obj["startDateTime"]).Value;
Assert.AreEqual(TimeSpan.FromHours(9.5), dateTimeOffset.Offset);
Assert.AreEqual("07/19/2012 14:30:00 +09:30", dateTimeOffset.ToString(CultureInfo.InvariantCulture));
}
#endif
}
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE)