|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
3 | 3 | using System.Data;
|
| 4 | +using System.Linq; |
4 | 5 | using NUnit.Framework;
|
5 | 6 | using ServiceStack.DataAnnotations;
|
6 | 7 | using ServiceStack.Text;
|
@@ -250,22 +251,22 @@ public void Can_OrderBy_Fields_with_different_sort_directions()
|
250 | 251 | db.DropAndCreateTable<LetterFrequency>();
|
251 | 252 | db.DropAndCreateTable<LetterStat>();
|
252 | 253 |
|
253 |
| - var i = 0; |
| 254 | + var insertedIds = new List<long>(); |
254 | 255 | "A,B,B,C,C,C,D,D,E".Split(',').Each(letter => {
|
255 |
| - db.Insert(new LetterFrequency { Letter = letter }, selectIdentity: true); |
| 256 | + insertedIds.Add(db.Insert(new LetterFrequency { Letter = letter }, selectIdentity: true)); |
256 | 257 | });
|
257 | 258 |
|
258 | 259 | var rows = db.Select<LetterFrequency>(q => q.OrderByFields("Letter", "Id"));
|
259 | 260 | Assert.That(rows.Map(x => x.Letter), Is.EquivalentTo("A,B,B,C,C,C,D,D,E".Split(',')));
|
260 |
| - Assert.That(rows.Map(x => x.Id), Is.EquivalentTo("1,2,3,4,5,6,7,8,9".Split(',').Map(int.Parse))); |
| 261 | + Assert.That(rows.Map(x => x.Id), Is.EquivalentTo(insertedIds)); |
261 | 262 |
|
262 | 263 | rows = db.Select<LetterFrequency>(q => q.OrderByFields("Letter", "-Id"));
|
263 | 264 | Assert.That(rows.Map(x => x.Letter), Is.EquivalentTo("A,B,B,C,C,C,D,D,E".Split(',')));
|
264 |
| - Assert.That(rows.Map(x => x.Id), Is.EquivalentTo("1,3,2,6,5,4,8,7,9".Split(',').Map(int.Parse))); |
| 265 | + Assert.That(rows.Map(x => x.Id), Is.EquivalentTo(insertedIds)); |
265 | 266 |
|
266 | 267 | rows = db.Select<LetterFrequency>(q => q.OrderByFieldsDescending("Letter", "-Id"));
|
267 | 268 | Assert.That(rows.Map(x => x.Letter), Is.EquivalentTo("E,D,D,C,C,C,B,B,A".Split(',')));
|
268 |
| - Assert.That(rows.Map(x => x.Id), Is.EquivalentTo("9,7,8,4,5,6,2,3,1".Split(',').Map(int.Parse))); |
| 269 | + Assert.That(rows.Map(x => x.Id), Is.EquivalentTo(Enumerable.Reverse(insertedIds))); |
269 | 270 | }
|
270 | 271 |
|
271 | 272 | }
|
|
0 commit comments