1- using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
4- using System . Text ;
5- using System . Text . RegularExpressions ;
6- using NUnit . Framework ;
7- using Simple . Data . SqlServer ;
8-
9- namespace Simple . Data . SqlTest
10- {
11- [ TestFixture ]
12- public class SqlQueryPagerTest
13- {
14- static readonly Regex Normalize = new Regex ( @"\s+" , RegexOptions . Multiline ) ;
15-
16- [ Test ]
17- public void ShouldApplyPagingUsingOrderBy ( )
18- {
19- const string sql = "select a,b,c from d where a = 1 order by c" ;
20- const string expected =
21- "with __data as (select a,b,c, row_number() over(order by c) as [_#_] from d where a = 1)"
22- + " select a,b,c from __data where [_#_] between @skip + 1 and @skip + @take" ;
23-
24- var modified = new SqlQueryPager ( ) . ApplyPaging ( sql , "@skip" , "@take" ) ;
25- modified = Normalize . Replace ( modified , " " ) . ToLowerInvariant ( ) ;
26-
27- Assert . AreEqual ( expected , modified ) ;
28- }
29-
30- [ Test ]
31- public void ShouldApplyPagingUsingOrderByFirstColumnIfNotAlreadyOrdered ( )
32- {
33- const string sql = "select a,b,c from d where a = 1" ;
34- const string expected =
35- "with __data as (select a,b,c, row_number() over(order by a) as [_#_] from d where a = 1)"
36- + " select a,b,c from __data where [_#_] between @skip + 1 and @skip + @take" ;
37-
38- var modified = new SqlQueryPager ( ) . ApplyPaging ( sql , "@skip" , "@take" ) ;
39- modified = Normalize . Replace ( modified , " " ) . ToLowerInvariant ( ) ;
40-
41- Assert . AreEqual ( expected , modified ) ;
42- }
43-
44- [ Test ]
1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Text ;
5+ using System . Text . RegularExpressions ;
6+ using NUnit . Framework ;
7+ using Simple . Data . SqlServer ;
8+
9+ namespace Simple . Data . SqlTest
10+ {
11+ [ TestFixture ]
12+ public class SqlQueryPagerTest
13+ {
14+ static readonly Regex Normalize = new Regex ( @"\s+" , RegexOptions . Multiline ) ;
15+
16+ [ Test ]
17+ public void ShouldApplyPagingUsingOrderBy ( )
18+ {
19+ const string sql = "select a,b,c from d where a = 1 order by c" ;
20+ const string expected =
21+ "with __data as (select a,b,c, row_number() over(order by c) as [_#_] from d where a = 1)"
22+ + " select a,b,c from __data where [_#_] between @skip + 1 and @skip + @take" ;
23+
24+ var modified = new SqlQueryPager ( ) . ApplyPaging ( sql , "@skip" , "@take" ) ;
25+ modified = Normalize . Replace ( modified , " " ) . ToLowerInvariant ( ) ;
26+
27+ Assert . AreEqual ( expected , modified ) ;
28+ }
29+
30+ [ Test ]
31+ public void ShouldApplyPagingUsingOrderByFirstColumnIfNotAlreadyOrdered ( )
32+ {
33+ const string sql = "select a,b,c from d where a = 1" ;
34+ const string expected =
35+ "with __data as (select a,b,c, row_number() over(order by a) as [_#_] from d where a = 1)"
36+ + " select a,b,c from __data where [_#_] between @skip + 1 and @skip + @take" ;
37+
38+ var modified = new SqlQueryPager ( ) . ApplyPaging ( sql , "@skip" , "@take" ) ;
39+ modified = Normalize . Replace ( modified , " " ) . ToLowerInvariant ( ) ;
40+
41+ Assert . AreEqual ( expected , modified ) ;
42+ }
43+
44+ [ Test ]
4545 public void ShouldCopeWithAliasedColumns ( )
4646 {
4747 const string sql = "select [a],[b] as [foo],[c] from [d] where [a] = 1" ;
@@ -53,6 +53,6 @@ public void ShouldCopeWithAliasedColumns()
5353 modified = Normalize . Replace ( modified , " " ) . ToLowerInvariant ( ) ;
5454
5555 Assert . AreEqual ( expected , modified ) ;
56- }
57- }
58- }
56+ }
57+ }
58+ }
0 commit comments