Skip to content

Commit

Permalink
Adding passing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ayende committed Aug 12, 2011
1 parent 734caf1 commit 28f100f
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
94 changes: 94 additions & 0 deletions Raven.Tests/Bugs/RacielrodTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using System.Linq;
using Raven.Client;
using Raven.Client.Document;
using Xunit;

namespace Raven.Tests.Bugs
{
public class RacielrodTest : RemoteClientTest
{
[Fact]
public void WhenNoQuery_CanOrderByNestedProperty()
{
using (GetNewServer())
using (var store = new DocumentStore {Url = "http://localhost:8080"})
{
store.Initialize();
using (IDocumentSession s = store.OpenSession())
{
for (int i = 0; i < 10; i++)
{
s.Store(new
{
Id = "tests/" + i,
Name = "Test" + i,
Content = new
{
Order = i,
Inserted = DateTime.Now.AddDays(i)
}
});
}
s.SaveChanges();
}
using (IDocumentSession s = store.OpenSession())
{
var objects =
s.Advanced.LuceneQuery<dynamic>()
.OrderBy("-Content.Order")
.Take(2)
.WaitForNonStaleResults()
.ToArray();

Assert.Equal(2, objects.Length);
Assert.Equal(9,
objects[0].Content.Order);
}
}
}


[Fact]
public void WheQuery_CanOrderByNestedProperty()
{
using(GetNewServer())
using (var store = new DocumentStore {Url = "http://localhost:8080"})
{
store.Initialize();
using (IDocumentSession s = store.OpenSession())
{
for (int i = 0; i < 10; i++)
{
s.Store(new
{
Id = "samples/" + i,
Name = "Sample" + i,
Body = new
{
Order = i,
Inserted = DateTime.Now.AddDays(i)
}
});
}
s.SaveChanges();
}
using (IDocumentSession s = store.OpenSession())
{
IDocumentQuery<dynamic> query =
s.Advanced.LuceneQuery<dynamic>()
.WhereBetweenOrEqual("Body.Inserted",
DateTime.Now.Date, DateTime.Now.AddDays(2))
.OrderBy("-Body.Order")
.Take(2)
.WaitForNonStaleResults();
var objects = query.ToArray();

Assert.Equal(2, objects.Length);
Assert.Equal(3, query.QueryResult.TotalResults);
Assert.Equal(2, objects[0].Body.Order);
}
}
}
}
}
1 change: 1 addition & 0 deletions Raven.Tests/Raven.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<Compile Include="Bugs\PoisonIndexes\PoisonIndex.cs" />
<Compile Include="Bugs\Queries\Boolean.cs" />
<Compile Include="Bugs\Queries\QueryProvider.cs" />
<Compile Include="Bugs\RacielrodTest.cs" />
<Compile Include="Bugs\SerializingAndDeserializingWithRaven.cs" />
<Compile Include="Bugs\CanGetScores.cs" />
<Compile Include="Bugs\CanReadLuceneProjectedDateTimeOffset.cs" />
Expand Down

0 comments on commit 28f100f

Please sign in to comment.