Created
February 24, 2014 00:28
-
-
Save mattjohnsonpint/9179529 to your computer and use it in GitHub Desktop.
Testing half-open interval date range
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using Raven.Tests.Helpers; | |
using Xunit; | |
namespace RavenTests | |
{ | |
public class DateRangeTest : RavenTestBase | |
{ | |
public class Foo | |
{ | |
public DateTime DateTime { get; set; } | |
} | |
[Fact] | |
public void Test() | |
{ | |
using (var documentStore = NewDocumentStore()) | |
{ | |
using (var session = documentStore.OpenSession()) | |
{ | |
session.Store(new Foo { DateTime = new DateTime(2014, 1, 1, 0, 0, 0, DateTimeKind.Utc) }); | |
session.Store(new Foo { DateTime = new DateTime(2014, 1, 2, 0, 0, 0, DateTimeKind.Utc) }); | |
session.Store(new Foo { DateTime = new DateTime(2014, 1, 3, 0, 0, 0, DateTimeKind.Utc) }); | |
session.SaveChanges(); | |
} | |
using (var session = documentStore.OpenSession()) | |
{ | |
var query = session.Advanced.LuceneQuery<Foo>() | |
.Where("DateTime:[2014-01-01T00:00:00.0000000Z TO 2014-01-03T00:00:00.0000000Z}") | |
.WaitForNonStaleResults(); | |
var results = query.ToList(); | |
Assert.Equal(2, results.Count); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment