-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
FirebirdTests.cs
57 lines (52 loc) · 2.23 KB
/
FirebirdTests.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
using FirebirdSql.Data.FirebirdClient;
using System.Data;
using System.Data.Common;
using System.Linq;
using Xunit;
namespace Dapper.Tests.Providers
{
/// <summary>
/// If Docker Desktop is installed, run the following command to start a container suitable for the tests.
/// <code>
/// docker run -d -p 3050:3050 --name Dapper.Tests.Firebird -e FIREBIRD_DATABASE=database -e ISC_PASSWORD=masterkey jacobalberty/firebird
/// </code>
/// </summary>
public class FirebirdProvider : DatabaseProvider
{
public override DbProviderFactory Factory => FirebirdClientFactory.Instance;
public override string GetConnectionString() => "initial catalog=localhost:database;user id=SYSDBA;password=masterkey";
}
public class FirebirdTests : TestBase<FirebirdProvider>
{
private FbConnection GetOpenFirebirdConnection() => (FbConnection)Provider.GetOpenConnection();
[Fact(Skip = "Bug in Firebird; a PR to fix it has been submitted")]
public void Issue178_Firebird()
{
using var connection = GetOpenFirebirdConnection();
const string sql = "select count(*) from Issue178";
try { connection.Execute("drop table Issue178"); }
catch { /* don't care */ }
connection.Execute("create table Issue178(id int not null)");
connection.Execute("insert into Issue178(id) values(42)");
// raw ADO.net
using (var sqlCmd = new FbCommand(sql, connection))
using (var reader1 = sqlCmd.ExecuteReader())
{
Assert.True(reader1.Read());
Assert.Equal(1, reader1.GetInt32(0));
Assert.False(reader1.Read());
Assert.False(reader1.NextResult());
}
// dapper
using (var reader2 = connection.ExecuteReader(sql))
{
Assert.True(reader2.Read());
Assert.Equal(1, reader2.GetInt32(0));
Assert.False(reader2.Read());
Assert.False(reader2.NextResult());
}
var count = connection.Query<int>(sql).Single();
Assert.Equal(1, count);
}
}
}