Skip to content

Commit c8a99c0

Browse files
authored
Add unit test for DateOnly and TimeOnly types (NET6.0+) (#341)
1 parent 2f9c180 commit c8a99c0

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/SmartFormat.Tests/Extensions/ReflectionSourceTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ private static object[] GetArgs()
2121
};
2222
}
2323

24+
#if NET
25+
[Test]
26+
public void DateOnly_TimeOnly()
27+
{
28+
var date = new DateOnly(2023, 12, 31);
29+
var time = new TimeOnly(23, 45, 56);
30+
31+
var result = Smart.Format("{0:dd.MM.yyyy} - {1:HH\\:mm\\:ss}", date, time);
32+
33+
Assert.That(result, Is.EqualTo("31.12.2023 - 23:45:56"));
34+
}
35+
#endif
36+
2437
[Test]
2538
public void Test_Properties()
2639
{
@@ -280,4 +293,4 @@ internal class TestReflectionSource : ReflectionSource
280293
{
281294
public static string TypeCacheFieldName => nameof(TypeCache);
282295
}
283-
}
296+
}

0 commit comments

Comments
 (0)