Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding passing tests

  • Loading branch information...
commit 28f100ff243a44e27cc980e175ceffaf4c5c06c0 1 parent 734caf1
@ayende ayende authored
View
94 Raven.Tests/Bugs/RacielrodTest.cs
@@ -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);
+ }
+ }
+ }
+ }
+}
View
1  Raven.Tests/Raven.Tests.csproj
@@ -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" />
Please sign in to comment.
Something went wrong with that request. Please try again.