forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMockDbConnection.cs
More file actions
113 lines (98 loc) · 3.5 KB
/
MockDbConnection.cs
File metadata and controls
113 lines (98 loc) · 3.5 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System;
using System.Data;
using System.Data.Common;
namespace Simple.Data.Mocking.Ado
{
public class MockDbConnection : DbConnection
{
private readonly MockDatabase _mockDatabase;
private ConnectionState _state = ConnectionState.Closed;
public MockDbConnection(MockDatabase mockDatabase)
{
_mockDatabase = mockDatabase;
}
public MockDatabase MockDatabase
{
get { return _mockDatabase; }
}
public DataTable DummyDataTable { get; set; }
/// <summary>
/// Starts a database transaction.
/// </summary>
/// <returns>
/// An object representing the new transaction.
/// </returns>
/// <param name="isolationLevel">Specifies the isolation level for the transaction.</param>
protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
{
return new MockDbTransaction(this, isolationLevel);
}
public override void Close()
{
_state = ConnectionState.Closed;
}
/// <summary>
/// Changes the current database for an open connection.
/// </summary>
/// <param name="databaseName">Specifies the name of the database for the connection to use.</param><filterpriority>2</filterpriority>
public override void ChangeDatabase(string databaseName)
{
throw new NotImplementedException();
}
public override string ConnectionString
{
get { return _mockDatabase.GetHashCode().ToString(); }
set
{
}
}
public override int ConnectionTimeout
{
get { throw new NotImplementedException(); }
}
/// <summary>
/// Creates and returns a <see cref="T:System.Data.Common.DbCommand"/> object associated with the current connection.
/// </summary>
/// <returns>
/// A <see cref="T:System.Data.Common.DbCommand"/> object.
/// </returns>
protected override DbCommand CreateDbCommand()
{
return new MockDbCommand(this);
}
public override string Database
{
get { throw new NotImplementedException(); }
}
/// <summary>
/// Gets the name of the database server to which to connect.
/// </summary>
/// <returns>
/// The name of the database server to which to connect. The default value is an empty string.
/// </returns>
/// <filterpriority>1</filterpriority>
public override string DataSource
{
get { throw new NotImplementedException(); }
}
public override void Open()
{
_state = ConnectionState.Open;
}
/// <summary>
/// Gets a string that represents the version of the server to which the object is connected.
/// </summary>
/// <returns>
/// The version of the database. The format of the string returned depends on the specific type of connection you are using.
/// </returns>
/// <filterpriority>2</filterpriority>
public override string ServerVersion
{
get { throw new NotImplementedException(); }
}
public override ConnectionState State
{
get { return _state; }
}
}
}