-Fixed test error when tests run in UTC timezone
-Fixed globalization warnings -Fixed SelectToken skipping last property name if it is a single character
This commit is contained in:
@@ -272,8 +272,16 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
c.DateTimeField = new DateTime(2008, 1, 1, 1, 1, 1, 0, DateTimeKind.Utc);
|
||||
string json2 = JsonConvert.SerializeObject(c, new IsoDateTimeConverter() { DateTimeStyles = DateTimeStyles.AssumeUniversal });
|
||||
|
||||
TimeSpan offset;
|
||||
|
||||
#if SILVERLIGHT
|
||||
offset = TimeZoneInfo.Local.GetUtcOffset(localDateTime);
|
||||
#else
|
||||
offset = TimeZone.CurrentTimeZone.GetUtcOffset(localDateTime);
|
||||
#endif
|
||||
|
||||
// if the current timezone is utc then local already equals utc
|
||||
if (TimeZone.CurrentTimeZone.GetUtcOffset(localDateTime) == TimeSpan.Zero)
|
||||
if (offset == TimeSpan.Zero)
|
||||
Assert.AreEqual(json, json2);
|
||||
else
|
||||
Assert.AreNotEqual(json, json2);
|
||||
|
||||
@@ -243,6 +243,15 @@ namespace Newtonsoft.Json.Tests.Linq
|
||||
Assert.AreEqual(3, (int)t);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EvaluateLastSingleCharacterProperty()
|
||||
{
|
||||
JObject o2 = JObject.Parse("{'People':[{'N':'Jeff'}]}");
|
||||
string a2 = (string)o2.SelectToken("People[0].N");
|
||||
|
||||
Assert.AreEqual("Jeff", a2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Example()
|
||||
{
|
||||
|
||||
@@ -594,28 +594,30 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple
|
||||
});
|
||||
|
||||
string urlStatusTypeName = ReflectionUtils.GetTypeName(typeof (UrlStatus), FormatterAssemblyStyle.Simple);
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""$type"": ""System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib"",
|
||||
""First"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TypeNameHandlingTests+UrlStatus, Newtonsoft.Json.Tests"",
|
||||
""$type"": """ + urlStatusTypeName + @""",
|
||||
""Status"": 404,
|
||||
""Url"": ""http://www.bing.com""
|
||||
},
|
||||
""Second"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TypeNameHandlingTests+UrlStatus, Newtonsoft.Json.Tests"",
|
||||
""$type"": """ + urlStatusTypeName + @""",
|
||||
""Status"": 400,
|
||||
""Url"": ""http://www.google.com""
|
||||
},
|
||||
""List"": {
|
||||
""$type"": ""System.Collections.Generic.List`1[[Newtonsoft.Json.Tests.Serialization.TypeNameHandlingTests+UrlStatus, Newtonsoft.Json.Tests]], mscorlib"",
|
||||
""$type"": ""System.Collections.Generic.List`1[[" + urlStatusTypeName + @"]], mscorlib"",
|
||||
""$values"": [
|
||||
{
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TypeNameHandlingTests+UrlStatus, Newtonsoft.Json.Tests"",
|
||||
""$type"": """ + urlStatusTypeName + @""",
|
||||
""Status"": 300,
|
||||
""Url"": ""http://www.yahoo.com""
|
||||
},
|
||||
{
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TypeNameHandlingTests+UrlStatus, Newtonsoft.Json.Tests"",
|
||||
""$type"": """ + urlStatusTypeName + @""",
|
||||
""Status"": 200,
|
||||
""Url"": ""http://www.askjeeves.com""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user