Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 335f543

Browse files
author
jmitchell
committed
Some failing tests for OrderByDescending.
1 parent d40974c commit 335f543

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System.Collections.Generic;
2+
using NUnit.Framework;
3+
using ServiceStack.OrmLite.Tests.Shared;
4+
5+
namespace ServiceStack.OrmLite.Tests.Issues
6+
{
7+
[TestFixture]
8+
public class MultiColumnOrderByDescending : OrmLiteTestBase
9+
{
10+
private List<Person> _people;
11+
12+
[TestFixtureSetUp]
13+
public new void TestFixtureSetUp()
14+
{
15+
_people = new List<Person>
16+
{
17+
new Person
18+
{
19+
Id = 1,
20+
FirstName = "Aaron",
21+
LastName = "Anderson"
22+
},
23+
new Person
24+
{
25+
Id = 2,
26+
FirstName = "Zack",
27+
LastName = "Zimmerman"
28+
}
29+
};
30+
31+
using (var db = OpenDbConnection())
32+
{
33+
db.DropAndCreateTable<Person>();
34+
db.SaveAll(_people);
35+
}
36+
}
37+
38+
[Test]
39+
public void Does_orderbydescending_multiple_columns_using_orderby()
40+
{
41+
using (var db = OpenDbConnection())
42+
{
43+
var q = db.From<Person>().OrderBy(rn => new { sortA = Sql.Desc(rn.LastName), sortB = Sql.Desc(rn.FirstName) });
44+
45+
var result = db.Select(q);
46+
47+
Assert.That(result.Count, Is.EqualTo(2));
48+
Assert.That(result[0].Id, Is.EqualTo(2));
49+
}
50+
}
51+
52+
[Test]
53+
public void Does_orderbydescending_multiple_columns_using_orderbydescending()
54+
{
55+
using (var db = OpenDbConnection())
56+
{
57+
var q = db.From<Person>().OrderByDescending(p => new { p.LastName, p.FirstName });
58+
59+
var result = db.Select(q);
60+
61+
Assert.That(result.Count, Is.EqualTo(2));
62+
Assert.That(result[0].Id, Is.EqualTo(2));
63+
}
64+
}
65+
}
66+
}

tests/ServiceStack.OrmLite.Tests/ServiceStack.OrmLite.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
<Compile Include="Expression\SelectExpressionTests.cs" />
131131
<Compile Include="Issues\ComplexJoinWithAlias.cs" />
132132
<Compile Include="Issues\MismatchSchemaTests.cs" />
133+
<Compile Include="Issues\MultiColumnOrderByDescending.cs" />
133134
<Compile Include="Issues\MultiFieldReferenceTests.cs" />
134135
<Compile Include="Issues\MultithreadingIssueTests.cs" />
135136
<Compile Include="Issues\SaveDomainUserReferencesIssue.cs" />

0 commit comments

Comments
 (0)