-
-
Notifications
You must be signed in to change notification settings - Fork 524
Expand file tree
/
Copy pathPostgreSqlLimitTests.cs
More file actions
58 lines (48 loc) · 1.64 KB
/
PostgreSqlLimitTests.cs
File metadata and controls
58 lines (48 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using SqlKata.Compilers;
using SqlKata.Tests.Infrastructure;
using Xunit;
namespace SqlKata.Tests.PostgreSql
{
public class PostgreSqlLimitTests : TestSupport
{
private readonly PostgresCompiler compiler;
public PostgreSqlLimitTests()
{
compiler = Compilers.Get<PostgresCompiler>(EngineCodes.PostgreSql);
}
[Fact]
public void WithNoLimitNorOffset()
{
var query = new Query("Table");
var ctx = new SqlResult(compiler) { Query = query };
Assert.Null(compiler.CompileLimit(ctx));
}
[Fact]
public void WithNoOffset()
{
var query = new Query("Table").Limit(10);
var ctx = new SqlResult(compiler) { Query = query };
Assert.Equal("LIMIT ?", compiler.CompileLimit(ctx));
Assert.Equal(10, ctx.Bindings[0]);
}
[Fact]
public void WithNoLimit()
{
var query = new Query("Table").Offset(20);
var ctx = new SqlResult(compiler) { Query = query };
Assert.Equal("OFFSET ?", compiler.CompileLimit(ctx));
Assert.Equal(20L, ctx.Bindings[0]);
Assert.Single(ctx.Bindings);
}
[Fact]
public void WithLimitAndOffset()
{
var query = new Query("Table").Limit(5).Offset(20);
var ctx = new SqlResult(compiler) { Query = query };
Assert.Equal("LIMIT ? OFFSET ?", compiler.CompileLimit(ctx));
Assert.Equal(5, ctx.Bindings[0]);
Assert.Equal(20L, ctx.Bindings[1]);
Assert.Equal(2, ctx.Bindings.Count);
}
}
}