Skip to content

Commit

Permalink
adding failing OrderByDescending tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fschwiet committed Sep 6, 2010
1 parent 8543792 commit 8515240
Showing 1 changed file with 64 additions and 19 deletions.
83 changes: 64 additions & 19 deletions Raven.Client.Tests/Bugs/SortingOnLong.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Raven.Database.Indexing;
using Xunit;
using System.Linq;
Expand All @@ -6,12 +7,11 @@ namespace Raven.Client.Tests.Bugs
{
public class SortingOnLong : LocalClientTest
{
[Fact]
public void CanSortOnLong()
void UsingDatabaseOfFoos(Action<IDocumentSession> action)
{
using(var store = NewDocumentStore())
using (var store = NewDocumentStore())
{
using(var session = store.OpenSession())
using (var session = store.OpenSession())
{
session.Store(new Foo
{
Expand All @@ -32,28 +32,73 @@ public void CanSortOnLong()
}

store.DatabaseCommands.PutIndex("long",
new IndexDefinition
{
Map = "from doc in docs select new { doc.Value }",
SortOptions = {{"Value", SortOptions.Long}}
});
new IndexDefinition
{
Map = "from doc in docs select new { doc.Value }",
SortOptions = { { "Value", SortOptions.Long } }
});

using (var session = store.OpenSession())
{
var foos = session.LuceneQuery<Foo>("long")
.WaitForNonStaleResults()
.OrderBy("Value_Range")
.ToList();

Assert.Equal(3, foos.Count);

Assert.Equal(25, foos[0].Value);
Assert.Equal(3147483647, foos[1].Value);
Assert.Equal(30000000000, foos[2].Value);
action(session);
}
}
}

[Fact]
public void CanSortOnLong()
{
UsingDatabaseOfFoos(delegate(IDocumentSession session)
{
var foos1 = session.LuceneQuery<Foo>("long")
.WaitForNonStaleResults()
.OrderBy("Value_Range")
.ToList();

Assert.Equal(3, foos1.Count);

Assert.Equal(25, foos1[0].Value);
Assert.Equal(3147483647, foos1[1].Value);
Assert.Equal(30000000000, foos1[2].Value);
});
}

[Fact(Skip = "Fails with foos1[0]==25, not 30000000000")]
public void CanSortOnLongDescending()
{
UsingDatabaseOfFoos(delegate(IDocumentSession session)
{
var foos1 = session.LuceneQuery<Foo>("long")
.WaitForNonStaleResults()
.OrderBy("-Value_Range")
.ToList();

Assert.Equal(3, foos1.Count);

Assert.Equal(30000000000, foos1[0].Value);
Assert.Equal(3147483647, foos1[1].Value);
Assert.Equal(25, foos1[2].Value);
});
}

[Fact(Skip = "Fails with foos1[0]==25, not 30000000000")]
public void CanLinqSortOnLongDescending()
{
UsingDatabaseOfFoos(delegate(IDocumentSession session)
{
var foos1 = session.Query<Foo>("long")
.Customize(q => q.WaitForNonStaleResults())
.OrderByDescending(f => f.Value)
.ToList();

Assert.Equal(3, foos1.Count);

Assert.Equal(30000000000, foos1[0].Value);
Assert.Equal(3147483647, foos1[1].Value);
Assert.Equal(25, foos1[2].Value);
});
}

public class Foo
{
public string Id { get; set; }
Expand Down

0 comments on commit 8515240

Please sign in to comment.