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

Commit 21cce43

Browse files
committed
Add date range tes
1 parent ae475ac commit 21cce43

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/ServiceStack.OrmLite.Tests/Issues/UtcDateTimeIssueTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using NUnit.Framework;
34
using ServiceStack.Text;
45

@@ -41,6 +42,34 @@ public void Test_DateTime_Select()
4142
}
4243
}
4344

45+
[Test]
46+
public void Can_select_DateTime_by_Range()
47+
{
48+
using (var db = OpenDbConnection())
49+
{
50+
db.DropAndCreateTable<TestDate>();
51+
52+
db.Insert(new TestDate {
53+
Name = "Now",
54+
ExpiryDate = DateTime.Now,
55+
});
56+
db.Insert(new TestDate {
57+
Name = "Today",
58+
ExpiryDate = DateTime.Now.Date,
59+
});
60+
db.Insert(new TestDate {
61+
Name = "Tomorrow",
62+
ExpiryDate = DateTime.Now.Date.AddDays(1),
63+
});
64+
65+
var results = db.Select<TestDate>()
66+
.Where(x => x.ExpiryDate >= DateTime.Now.Date &&
67+
x.ExpiryDate < DateTime.Now.Date.AddDays(1));
68+
69+
Assert.That(results.Map(x => x.Name), Is.EquivalentTo(new[]{"Now","Today"}));
70+
}
71+
}
72+
4473
[Test]
4574
public void Can_Select_DateTime_with_SelectFmt()
4675
{

0 commit comments

Comments
 (0)