-Test
This commit is contained in:
@@ -7858,6 +7858,31 @@ Parameter name: value",
|
|||||||
Assert.AreEqual("abc", v.Value);
|
Assert.AreEqual("abc", v.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DateFormatStringWithDictionaryKey()
|
||||||
|
{
|
||||||
|
DateTime dt = new DateTime(2000, 12, 22);
|
||||||
|
string dateFormatString = "yyyy'-pie-'MMM'-'dddd'-'dd";
|
||||||
|
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
DateFormatString = dateFormatString,
|
||||||
|
Formatting = Formatting.Indented
|
||||||
|
};
|
||||||
|
|
||||||
|
string json = JsonConvert.SerializeObject(new Dictionary<DateTime, string>
|
||||||
|
{
|
||||||
|
{ dt, "123" }
|
||||||
|
}, settings);
|
||||||
|
|
||||||
|
Assert.AreEqual(@"{
|
||||||
|
""2000-pie-Dec-Friday-22"": ""123""
|
||||||
|
}", json);
|
||||||
|
|
||||||
|
Dictionary<DateTime, string> d = JsonConvert.DeserializeObject<Dictionary<DateTime, string>>(json, settings);
|
||||||
|
|
||||||
|
Assert.AreEqual(dt, d.Keys.ElementAt(0));
|
||||||
|
}
|
||||||
|
|
||||||
#if !NET20
|
#if !NET20
|
||||||
[Test]
|
[Test]
|
||||||
public void DateFormatStringWithDateTimeOffset()
|
public void DateFormatStringWithDateTimeOffset()
|
||||||
|
|||||||
Reference in New Issue
Block a user