Permalink
Browse files

Adding passing test

  • Loading branch information...
1 parent bc92424 commit 64f11885d56d40153bacaf31a5a4cfafe4e22c7c @ayende ayende committed Jun 19, 2011
Showing with 60 additions and 3 deletions.
  1. +60 −3 Raven.Tests/Bugs/NullableDateTime.cs
@@ -1,4 +1,8 @@
using System;
+using Raven.Abstractions.Indexing;
+using Raven.Client;
+using Raven.Client.Indexes;
+using Raven.Client.Linq;
using Xunit;
using System.Linq;
@@ -9,9 +13,9 @@ public class NullableDateTime : LocalClientTest
[Fact]
public void WillNotIncludeItemsWithNullDate()
{
- using(var store = NewDocumentStore())
+ using (var store = NewDocumentStore())
{
- using(var session = store.OpenSession())
+ using (var session = store.OpenSession())
{
session.Store(new WithNullableDateTime());
session.SaveChanges();
@@ -20,7 +24,7 @@ public void WillNotIncludeItemsWithNullDate()
using (var session = store.OpenSession())
{
var withNullableDateTimes = session.Query<WithNullableDateTime>()
- .Customize(x=>x.WaitForNonStaleResults())
+ .Customize(x => x.WaitForNonStaleResults())
.Where(x => x.CreatedAt > new DateTime(2000, 1, 1) && x.CreatedAt != null)
.ToList();
Assert.Empty(withNullableDateTimes);
@@ -33,5 +37,58 @@ public class WithNullableDateTime
public string Id { get; set; }
public DateTime? CreatedAt { get; set; }
}
+
+ public class Doc
+ {
+ public string Id { get; set; }
+ public DateTime? Date { get; set; }
+ }
+
+ public class DocSummary
+ {
+ public string Id { get; set; }
+ public DateTime? MaxDate { get; set; }
+ }
+
+ public class UnsetDocs : AbstractIndexCreationTask<Doc, DocSummary>
+ {
+ public UnsetDocs()
+ {
+ Map = docs =>
+ from doc in docs
+ select new
+ {
+ doc.Id,
+ MaxDate = doc.Date
+ };
+ Store(x => x.MaxDate, FieldStorage.Yes);
+ }
+ }
+
+ [Fact]
+ public void CanLoadFromIndex()
+ {
+ using (var documentStore = NewDocumentStore())
+ {
+ using (IDocumentSession session = documentStore.OpenSession())
+ {
+ IndexCreation.CreateIndexes(typeof(Doc).Assembly, documentStore);
+ session.Store(new Doc { Id = "test/doc1", Date = DateTime.UtcNow });
+ session.Store(new Doc { Id = "test/doc2", Date = null });
+ session.SaveChanges();
+
+ }
+
+ using (var session = documentStore.OpenSession())
+ {
+ session
+ .Query<Doc, UnsetDocs>()
+ .Customize(x => x.WaitForNonStaleResults())
+ .AsProjection<DocSummary>()
+ .ToArray();
+ }
+ }
+
+ }
}
}

0 comments on commit 64f1188

Please sign in to comment.