Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 893bfb6

Browse files
committed
Add Include Nulls in List tests
1 parent ed3c332 commit 893bfb6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/ServiceStack.Text.Tests/JsonTests/BasicJsonTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,5 +567,27 @@ public void Can_run_FromJson_within_RawDeserializeFn()
567567

568568
Assert.That(obj.Bar, Is.EqualTo("Bar"));
569569
}
570+
571+
[Test]
572+
public void Does_include_null_values_in_lists()
573+
{
574+
using (JsConfig.With(includeNullValues:true))
575+
{
576+
var dto = new List<DateTime?>
577+
{
578+
new DateTime(2000, 01, 01, 0, 0, 0, 0, DateTimeKind.Utc),
579+
null,
580+
new DateTime(2000, 12, 31, 0, 0, 0, 0, DateTimeKind.Utc),
581+
};
582+
583+
var json = dto.ToJson();
584+
585+
Assert.That(json, Is.EqualTo(@"[""\/Date(946684800000)\/"",null,""\/Date(978220800000)\/""]"));
586+
587+
var fromJson = json.FromJson<List<DateTime?>>();
588+
589+
Assert.That(fromJson.Count, Is.EqualTo(dto.Count));
590+
}
591+
}
570592
}
571593
}

0 commit comments

Comments
 (0)