forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInMemoryDbConnection.cs
More file actions
75 lines (63 loc) · 1.33 KB
/
InMemoryDbConnection.cs
File metadata and controls
75 lines (63 loc) · 1.33 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System.Data;
using ServiceStack.OrmLite;
namespace ServiceStack.ServiceHost.Tests.Support
{
/// <summary>
/// LAMO hack I'm forced to do to because I can't register a simple delegate
/// to create my instance type
/// </summary>
public class InMemoryDbConnection
: IDbConnection
{
private readonly IDbConnection inner;
public InMemoryDbConnection()
{
this.inner = ":memory:".OpenDbConnection();
}
public void Dispose()
{
this.inner.Dispose();
}
public IDbTransaction BeginTransaction()
{
return this.inner.BeginTransaction();
}
public IDbTransaction BeginTransaction(IsolationLevel il)
{
return this.inner.BeginTransaction(il);
}
public void Close()
{
this.inner.Close();
}
public void ChangeDatabase(string databaseName)
{
this.inner.ChangeDatabase(databaseName);
}
public IDbCommand CreateCommand()
{
return this.inner.CreateCommand();
}
public void Open()
{
this.inner.Open();
}
public string ConnectionString
{
get { return this.inner.ConnectionString; }
set { this.inner.ConnectionString = value; }
}
public int ConnectionTimeout
{
get { return this.inner.ConnectionTimeout; }
}
public string Database
{
get { return this.inner.Database; }
}
public ConnectionState State
{
get { return this.inner.State; }
}
}
}