Skip to content

Commit fe6c861

Browse files
committed
Update JsonTests.cs
Added test case for unix timestamps in milliseconds
1 parent 152f762 commit fe6c861

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

RestSharp.Tests/JsonTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,17 @@ public void Can_Deserialize_Unix_Json_Dates()
623623
Assert.AreEqual(new DateTime(2011, 6, 30, 8, 15, 46, DateTimeKind.Utc), bd.Value);
624624
}
625625

626+
[Test]
627+
public void Can_Deserialize_Unix_Json_Millisecond_Dates()
628+
{
629+
string doc = CreateUnixDateMillisecondsJson();
630+
JsonDeserializer d = new JsonDeserializer();
631+
RestResponse response = new RestResponse { Content = doc };
632+
Birthdate bd = d.Deserialize<Birthdate>(response);
633+
634+
Assert.AreEqual(new DateTime(2011, 6, 30, 8, 15, 46, DateTimeKind.Utc), bd.Value);
635+
}
636+
626637
[Test]
627638
public void Can_Deserialize_JsonNet_Dates()
628639
{
@@ -910,6 +921,15 @@ private static string CreateUnixDateJson()
910921
return doc.ToString();
911922
}
912923

924+
private static string CreateUnixDateMillisecondsJson()
925+
{
926+
JsonObject doc = new JsonObject();
927+
928+
doc["Value"] = 1309421746000;
929+
930+
return doc.ToString();
931+
}
932+
913933
private static string CreateJson()
914934
{
915935
JsonObject doc = new JsonObject();

0 commit comments

Comments
 (0)