Skip to content

Instantly share code, notes, and snippets.

@mattjohnsonpint
Created February 24, 2014 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattjohnsonpint/9179529 to your computer and use it in GitHub Desktop.
Save mattjohnsonpint/9179529 to your computer and use it in GitHub Desktop.
Testing half-open interval date range
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