-
Notifications
You must be signed in to change notification settings - Fork 4
/
DapperTest.cs
77 lines (66 loc) · 1.31 KB
/
DapperTest.cs
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using Carbunql.Building;
using Xunit.Abstractions;
namespace Carbunql.Dapper.Test;
public class LoadTest : IClassFixture<PostgresDB>
{
public LoadTest(PostgresDB postgresDB, ITestOutputHelper output)
{
PostgresDB = postgresDB;
Logger = new UnitTestLogger() { Output = output };
}
private readonly PostgresDB PostgresDB;
private readonly UnitTestLogger Logger;
[Fact]
public void ExecuteReader_NoParamter()
{
using var cn = PostgresDB.ConnectionOpenAsNew(Logger);
var sql = @"with
data_ds(c1, c2) as (
values
(1,2)
, (3,4)
)
select
*
from
data_ds
";
var sq = SelectQuery.Parse(sql);
using var r = cn.ExecuteReader(sq);
var cnt = 0;
while (r.Read())
{
cnt++;
}
Assert.Equal(2, cnt);
}
[Fact]
public void ExecuteReader_HasParamter()
{
using var cn = PostgresDB.ConnectionOpenAsNew(Logger);
var sql = @"with
data_ds(c1, c2) as (
values
(1,1)
, (1,2)
, (2,1)
, (2,2)
)
select
*
from
data_ds
where
c1 = :val
";
var sq = SelectQuery.Parse(sql);
sq.AddParameter(":val", 1);
using var r = cn.ExecuteReader(sq);
var cnt = 0;
while (r.Read())
{
cnt++;
}
Assert.Equal(2, cnt);
}
}