Skip to content

Commit 240225d

Browse files
author
Nick Berardi
committed
added test for unix datetime
1 parent 3143fc4 commit 240225d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

RestSharp.Tests/JsonTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,17 @@ public void Can_Deserialize_JScript_Json_Dates()
312312
Assert.Equal(new DateTime(1910, 9, 25, 9, 30, 25, DateTimeKind.Utc), bd.Value);
313313
}
314314

315+
[Fact]
316+
public void Can_Deserialize_Unix_Json_Dates()
317+
{
318+
var doc = CreateUnixDateJson();
319+
var d = new JsonDeserializer();
320+
var response = new RestResponse { Content = doc };
321+
var bd = d.Deserialize<Birthdate>(response);
322+
323+
Assert.Equal(new DateTime(2011, 6, 30, 8, 15, 46, DateTimeKind.Utc), bd.Value);
324+
}
325+
315326
[Fact]
316327
public void Can_Deserialize_JsonNet_Dates()
317328
{
@@ -511,6 +522,14 @@ private string CreateJScriptDateJson()
511522
return JsonConvert.SerializeObject(bd, new JavaScriptDateTimeConverter());
512523
}
513524

525+
private string CreateUnixDateJson()
526+
{
527+
var doc = new JObject();
528+
doc["Value"] = 1309421746;
529+
530+
return doc.ToString();
531+
}
532+
514533
private string CreateJson()
515534
{
516535
var doc = new JObject();

0 commit comments

Comments
 (0)