File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
src/MySqlConnector/MySql.Data.MySqlClient Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 16
16
namespace MySql . Data . MySqlClient
17
17
{
18
18
public sealed class MySqlConnection : DbConnection
19
+ #if ! NETSTANDARD1_3
20
+ , ICloneable
21
+ #endif
19
22
{
20
23
public MySqlConnection ( )
21
24
: this ( default )
@@ -438,6 +441,12 @@ public override async ValueTask DisposeAsync()
438
441
}
439
442
}
440
443
444
+ public MySqlConnection Clone ( ) => new MySqlConnection ( m_connectionString ) ;
445
+
446
+ #if ! NETSTANDARD1_3
447
+ object ICloneable . Clone ( ) => Clone ( ) ;
448
+ #endif
449
+
441
450
internal ServerSession Session
442
451
{
443
452
get
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Data ;
2
3
using Dapper ;
3
4
using MySql . Data . MySqlClient ;
4
5
using Xunit ;
@@ -141,5 +142,25 @@ public void ConnectionTimeoutExplicitValueAfterOpen()
141
142
connection . Open ( ) ;
142
143
Assert . Equal ( 30 , connection . ConnectionTimeout ) ;
143
144
}
145
+
146
+ [ Fact ]
147
+ public void CloneClonesConnectionString ( )
148
+ {
149
+ using var connection = new MySqlConnection ( AppConfig . ConnectionString ) ;
150
+ using var connection2 = ( MySqlConnection ) connection . Clone ( ) ;
151
+ Assert . Equal ( connection . ConnectionString , connection2 . ConnectionString ) ;
152
+ #if ! BASELINE
153
+ Assert . Equal ( AppConfig . ConnectionString , connection2 . ConnectionString ) ;
154
+ #endif
155
+ }
156
+
157
+ [ Fact ]
158
+ public void CloneIsClosed ( )
159
+ {
160
+ using var connection = new MySqlConnection ( AppConfig . ConnectionString ) ;
161
+ connection . Open ( ) ;
162
+ using var connection2 = ( MySqlConnection ) connection . Clone ( ) ;
163
+ Assert . Equal ( ConnectionState . Closed , connection2 . State ) ;
164
+ }
144
165
}
145
166
}
You can’t perform that action at this time.
0 commit comments