File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed
src/MySqlConnector/MySql.Data.MySqlClient Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -226,7 +226,7 @@ internal IDisposable RegisterCancel(CancellationToken token)
226226 internal void ResetCommandTimeout ( )
227227 {
228228 var commandTimeout = CommandTimeout ;
229- Connection . Session . SetTimeout ( commandTimeout == 0 ? Constants . InfiniteTimeout : commandTimeout * 1000 ) ;
229+ Connection ? . Session ? . SetTimeout ( commandTimeout == 0 ? Constants . InfiniteTimeout : commandTimeout * 1000 ) ;
230230 }
231231
232232 private void VerifyNotDisposed ( )
Original file line number Diff line number Diff line change 1+ using System ;
2+ using MySql . Data . MySqlClient ;
3+ using Xunit ;
4+
5+ namespace SideBySide
6+ {
7+ public class CommandTests : IClassFixture < DatabaseFixture >
8+ {
9+ public CommandTests ( DatabaseFixture database )
10+ {
11+ m_database = database ;
12+ }
13+
14+ [ Fact ]
15+ public void CreateCommandSetsConnection ( )
16+ {
17+ using ( var command = m_database . Connection . CreateCommand ( ) )
18+ {
19+ Assert . Equal ( m_database . Connection , command . Connection ) ;
20+ }
21+ }
22+
23+ [ Fact ]
24+ public void ExecuteReaderRequiresConnection ( )
25+ {
26+ using ( var command = new MySqlCommand ( ) )
27+ {
28+ Assert . Throws < InvalidOperationException > ( ( ) => command . ExecuteReader ( ) ) ;
29+ }
30+ }
31+
32+ [ Fact ]
33+ public void ExecuteReaderRequiresOpenConnection ( )
34+ {
35+ using ( var connection = new MySqlConnection ( ) )
36+ using ( var command = connection . CreateCommand ( ) )
37+ {
38+ Assert . Throws < InvalidOperationException > ( ( ) => command . ExecuteReader ( ) ) ;
39+ }
40+ }
41+
42+ readonly DatabaseFixture m_database ;
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments