[System*] Throw a PlatformNotSupported exception when using the managed networking...
[mono-project.git] / mcs / class / System.Data / Test / System.Data.SqlClient / SqlConnectionTest.cs
blob9511be24f7535375f8298d0c559a174d70452296
1 //
2 // SqlConnectionTest.cs - NUnit Test Cases for testing the
3 // SqlConnection class
4 // Author:
5 // Gert Driesen (drieseng@users.sourceforge.net)
6 //
7 // Copyright (c) 2004 Novell Inc., and the individuals listed
8 // on the ChangeLog entries.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System;
31 using System.Data;
32 using System.Data.SqlClient;
34 using NUnit.Framework;
36 namespace MonoTests.System.Data.SqlClient
38 [TestFixture]
39 public class SqlConnectionTest
41 [Test] // SqlConnection ()
42 #if FEATURE_NO_BSD_SOCKETS
43 [ExpectedException (typeof (PlatformNotSupportedException))]
44 #endif
45 public void Constructor1 ()
47 SqlConnection cn = new SqlConnection ();
49 Assert.AreEqual (string.Empty, cn.ConnectionString, "#1");
50 Assert.AreEqual (15, cn.ConnectionTimeout, "#2");
51 Assert.IsNull (cn.Container, "#3");
52 Assert.AreEqual (string.Empty, cn.Database, "#4");
53 Assert.AreEqual (string.Empty, cn.DataSource, "#5");
54 Assert.IsFalse (cn.FireInfoMessageEventOnUserErrors, "#6");
55 Assert.AreEqual (8000, cn.PacketSize, "#7");
56 Assert.IsNull (cn.Site, "#8");
57 Assert.AreEqual (ConnectionState.Closed, cn.State, "#9");
58 Assert.IsFalse (cn.StatisticsEnabled, "#10");
59 Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#11");
62 [Test] // SqlConnection (string)
63 #if FEATURE_NO_BSD_SOCKETS
64 [ExpectedException (typeof (PlatformNotSupportedException))]
65 #endif
66 public void Constructor2 ()
68 string connectionString = "server=SQLSRV; database=Mono;";
70 SqlConnection cn = new SqlConnection (connectionString);
71 Assert.AreEqual (connectionString, cn.ConnectionString, "#A1");
72 Assert.AreEqual (15, cn.ConnectionTimeout, "#A2");
73 Assert.IsNull (cn.Container, "#A3");
74 Assert.AreEqual ("Mono", cn.Database, "#A4");
75 Assert.AreEqual ("SQLSRV", cn.DataSource, "#A5");
76 Assert.IsFalse (cn.FireInfoMessageEventOnUserErrors, "#A6");
77 Assert.AreEqual (8000, cn.PacketSize, "#A7");
78 Assert.IsNull (cn.Site, "#A8");
79 Assert.AreEqual (ConnectionState.Closed, cn.State, "#A9");
80 Assert.IsFalse (cn.StatisticsEnabled, "#A10");
81 Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#A11");
83 cn = new SqlConnection ((string) null);
84 Assert.AreEqual (string.Empty, cn.ConnectionString, "#B1");
85 Assert.AreEqual (15, cn.ConnectionTimeout, "#B2");
86 Assert.IsNull (cn.Container, "#B3");
87 Assert.AreEqual (string.Empty, cn.Database, "#B4");
88 Assert.AreEqual (string.Empty, cn.DataSource, "#B5");
89 Assert.IsFalse (cn.FireInfoMessageEventOnUserErrors, "#B6");
90 Assert.AreEqual (8000, cn.PacketSize, "#B7");
91 Assert.IsNull (cn.Site, "#B8");
92 Assert.AreEqual (ConnectionState.Closed, cn.State, "#B9");
93 Assert.IsFalse (cn.StatisticsEnabled, "#B10");
94 Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#B11");
97 [Test]
98 #if FEATURE_NO_BSD_SOCKETS
99 [ExpectedException (typeof (PlatformNotSupportedException))]
100 #endif
101 public void Constructor2_ConnectionString_Invalid ()
103 try {
104 new SqlConnection ("InvalidConnectionString");
105 Assert.Fail ("#A1");
106 } catch (ArgumentException ex) {
107 // Format of the initialization string does
108 // not conform to specification starting at
109 // index 0
110 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
111 Assert.IsNull (ex.InnerException, "#A3");
112 Assert.IsNotNull (ex.Message, "#A4");
113 Assert.IsNull (ex.ParamName, "#A5");
116 // invalid keyword
117 try {
118 new SqlConnection ("invalidKeyword=10");
119 Assert.Fail ("#B1");
120 } catch (ArgumentException ex) {
121 // Keyword not supported: 'invalidkeyword'
122 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
123 Assert.IsNull (ex.InnerException, "#B3");
124 Assert.IsNotNull (ex.Message, "#B4");
125 Assert.IsTrue (ex.Message.IndexOf ("'invalidkeyword'") != -1, "#B5");
126 Assert.IsNull (ex.ParamName, "#B6");
129 // invalid packet size (< minimum)
130 try {
131 new SqlConnection ("Packet Size=511");
132 Assert.Fail ("#C1");
133 } catch (ArgumentException ex) {
134 // Invalid 'Packet Size'. The value must be an
135 // integer >= 512 and <= 32768
136 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
137 Assert.IsNull (ex.InnerException, "#C3");
138 Assert.IsNotNull (ex.Message, "#C4");
139 Assert.IsNull (ex.ParamName, "#C5");
142 // invalid packet size (> maximum)
143 try {
144 new SqlConnection ("Packet Size=32769");
145 Assert.Fail ("#D1");
146 } catch (ArgumentException ex) {
147 // Invalid 'Packet Size'. The value must be an
148 // integer >= 512 and <= 32768
149 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
150 Assert.IsNull (ex.InnerException, "#D3");
151 Assert.IsNotNull (ex.Message, "#D4");
152 Assert.IsNull (ex.ParamName, "#D5");
155 // negative connect timeout
156 try {
157 new SqlConnection ("Connect Timeout=-1");
158 Assert.Fail ("#E1");
159 } catch (ArgumentException ex) {
160 // Invalid value for key 'connect timeout'
161 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#E2");
162 Assert.IsNull (ex.InnerException, "#E3");
163 Assert.IsNotNull (ex.Message, "#E4");
164 Assert.IsNull (ex.ParamName, "#E5");
167 // negative max pool size
168 try {
169 new SqlConnection ("Max Pool Size=-1");
170 Assert.Fail ("#F1");
171 } catch (ArgumentException ex) {
172 // Invalid value for key 'max pool size'
173 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#F2");
174 Assert.IsNull (ex.InnerException, "#F3");
175 Assert.IsNotNull (ex.Message, "#F4");
176 Assert.IsNull (ex.ParamName, "#F5");
179 // negative min pool size
180 try {
181 new SqlConnection ("Min Pool Size=-1");
182 Assert.Fail ("#G1");
183 } catch (ArgumentException ex) {
184 // Invalid value for key 'min pool size'
185 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#G2");
186 Assert.IsNull (ex.InnerException, "#G3");
187 Assert.IsNotNull (ex.Message, "#G4");
188 Assert.IsNull (ex.ParamName, "#G5");
192 [Test]
193 #if FEATURE_NO_BSD_SOCKETS
194 [ExpectedException (typeof (PlatformNotSupportedException))]
195 #endif
196 public void BeginTransaction_Connection_Closed ()
198 SqlConnection cn = new SqlConnection ();
200 try {
201 cn.BeginTransaction ();
202 Assert.Fail ("#A1");
203 } catch (InvalidOperationException ex) {
204 // Invalid operation. The connection is closed
205 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
206 Assert.IsNull (ex.InnerException, "#A3");
207 Assert.IsNotNull (ex.Message, "#A4");
210 try {
211 cn.BeginTransaction ((IsolationLevel) 666);
212 Assert.Fail ("#B1");
213 } catch (InvalidOperationException ex) {
214 // Invalid operation. The connection is closed
215 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
216 Assert.IsNull (ex.InnerException, "#B3");
217 Assert.IsNotNull (ex.Message, "#B4");
220 try {
221 cn.BeginTransaction (IsolationLevel.Serializable);
222 Assert.Fail ("#C1");
223 } catch (InvalidOperationException ex) {
224 // Invalid operation. The connection is closed
225 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
226 Assert.IsNull (ex.InnerException, "#C3");
227 Assert.IsNotNull (ex.Message, "#C4");
230 try {
231 cn.BeginTransaction ("trans");
232 Assert.Fail ("#D1");
233 } catch (InvalidOperationException ex) {
234 // Invalid operation. The connection is closed
235 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
236 Assert.IsNull (ex.InnerException, "#D3");
237 Assert.IsNotNull (ex.Message, "#D4");
240 try {
241 cn.BeginTransaction ((IsolationLevel) 666, "trans");
242 Assert.Fail ("#E1");
243 } catch (InvalidOperationException ex) {
244 // Invalid operation. The connection is closed
245 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
246 Assert.IsNull (ex.InnerException, "#E3");
247 Assert.IsNotNull (ex.Message, "#E4");
250 try {
251 cn.BeginTransaction (IsolationLevel.Serializable, "trans");
252 Assert.Fail ("#F1");
253 } catch (InvalidOperationException ex) {
254 // Invalid operation. The connection is closed
255 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F2");
256 Assert.IsNull (ex.InnerException, "#F3");
257 Assert.IsNotNull (ex.Message, "#F4");
261 [Test]
262 #if FEATURE_NO_BSD_SOCKETS
263 [ExpectedException (typeof (PlatformNotSupportedException))]
264 #endif
265 public void ChangeDatabase_Connection_Closed ()
267 SqlConnection cn = new SqlConnection ();
268 cn.ConnectionString = "server=SQLSRV";
270 try {
271 cn.ChangeDatabase ("database");
272 Assert.Fail ("#1");
273 } catch (InvalidOperationException ex) {
274 // Invalid operation. The connection is closed
275 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
276 Assert.IsNull (ex.InnerException, "#3");
277 Assert.IsNotNull (ex.Message, "#4");
281 [Test]
282 #if FEATURE_NO_BSD_SOCKETS
283 [ExpectedException (typeof (PlatformNotSupportedException))]
284 #endif
285 public void ChangePassword_ConnectionString_Empty ()
287 try {
288 SqlConnection.ChangePassword (string.Empty, "mono");
289 Assert.Fail ("#1");
290 } catch (ArgumentNullException ex) {
291 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
292 Assert.IsNull (ex.InnerException, "#3");
293 Assert.IsNotNull (ex.Message, "#4");
294 Assert.IsNotNull (ex.ParamName, "#5");
295 Assert.IsTrue (ex.ParamName.IndexOf ("'connectionString'") != -1, "#6");
299 [Test]
300 #if FEATURE_NO_BSD_SOCKETS
301 [ExpectedException (typeof (PlatformNotSupportedException))]
302 #endif
303 public void ChangePassword_ConnectionString_Null ()
305 try {
306 SqlConnection.ChangePassword ((string) null, "mono");
307 Assert.Fail ("#1");
308 } catch (ArgumentNullException ex) {
309 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
310 Assert.IsNull (ex.InnerException, "#3");
311 Assert.IsNotNull (ex.Message, "#4");
312 Assert.IsNotNull (ex.ParamName, "#5");
313 Assert.IsTrue (ex.ParamName.IndexOf ("'connectionString'") != -1, "#6");
318 #if FEATURE_NO_BSD_SOCKETS
319 [ExpectedException (typeof (PlatformNotSupportedException))]
320 #endif
321 public void ChangePassword_NewPassword_Empty ()
323 try {
324 SqlConnection.ChangePassword ("server=SQLSRV", string.Empty);
325 Assert.Fail ("#1");
326 } catch (ArgumentNullException ex) {
327 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
328 Assert.IsNull (ex.InnerException, "#3");
329 Assert.IsNotNull (ex.Message, "#4");
330 Assert.IsNotNull (ex.ParamName, "#5");
331 Assert.IsTrue (ex.ParamName.IndexOf ("'newPassword'") != -1, "#6");
335 [Test]
336 #if FEATURE_NO_BSD_SOCKETS
337 [ExpectedException (typeof (PlatformNotSupportedException))]
338 #endif
339 public void ChangePassword_NewPassword_ExceedMaxLength ()
341 try {
342 SqlConnection.ChangePassword ("server=SQLSRV",
343 new string ('d', 129));
344 Assert.Fail ("#1");
345 } catch (ArgumentException ex) {
346 // The length of argument 'newPassword' exceeds
347 // it's limit of '128'
348 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
349 Assert.IsNull (ex.InnerException, "#3");
350 Assert.IsNotNull (ex.Message, "#4");
351 Assert.IsTrue (ex.Message.IndexOf ("'newPassword'") != -1, "#5");
352 Assert.IsTrue (ex.Message.IndexOf ("128") != -1, "#6");
353 Assert.IsNull (ex.ParamName, "#7");
357 [Test]
358 #if FEATURE_NO_BSD_SOCKETS
359 [ExpectedException (typeof (PlatformNotSupportedException))]
360 #endif
361 public void ChangePassword_NewPassword_Null ()
363 try {
364 SqlConnection.ChangePassword ("server=SQLSRV", (string) null);
365 Assert.Fail ("#1");
366 } catch (ArgumentNullException ex) {
367 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
368 Assert.IsNull (ex.InnerException, "#3");
369 Assert.IsNotNull (ex.Message, "#4");
370 Assert.IsNotNull (ex.ParamName, "#5");
371 Assert.IsTrue (ex.ParamName.IndexOf ("'newPassword'") != -1, "#6");
375 [Test]
376 #if FEATURE_NO_BSD_SOCKETS
377 [ExpectedException (typeof (PlatformNotSupportedException))]
378 #endif
379 public void ClearPool_Connection_Null ()
381 try {
382 SqlConnection.ClearPool ((SqlConnection) null);
383 Assert.Fail ("#1");
384 } catch (ArgumentNullException ex) {
385 Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
386 Assert.IsNull (ex.InnerException, "#3");
387 Assert.IsNotNull (ex.Message, "#4");
388 Assert.AreEqual ("connection", ex.ParamName, "#5");
392 [Test]
393 #if FEATURE_NO_BSD_SOCKETS
394 [ExpectedException (typeof (PlatformNotSupportedException))]
395 #endif
396 public void ConnectionString ()
398 SqlConnection cn = new SqlConnection ();
399 cn.ConnectionString = "server=SQLSRV";
400 Assert.AreEqual ("server=SQLSRV", cn.ConnectionString, "#1");
401 cn.ConnectionString = null;
402 Assert.AreEqual (string.Empty, cn.ConnectionString, "#2");
403 cn.ConnectionString = "server=SQLSRV";
404 Assert.AreEqual ("server=SQLSRV", cn.ConnectionString, "#3");
405 cn.ConnectionString = string.Empty;
406 Assert.AreEqual (string.Empty, cn.ConnectionString, "#4");
409 [Test]
410 #if FEATURE_NO_BSD_SOCKETS
411 [ExpectedException (typeof (PlatformNotSupportedException))]
412 #endif
413 public void ConnectionString_Value_Invalid ()
415 SqlConnection cn = new SqlConnection ();
417 try {
418 cn.ConnectionString = "InvalidConnectionString";
419 Assert.Fail ("#A1");
420 } catch (ArgumentException ex) {
421 // Format of the initialization string does
422 // not conform to specification starting at
423 // index 0
424 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
425 Assert.IsNull (ex.InnerException, "#A3");
426 Assert.IsNotNull (ex.Message, "#A4");
427 Assert.IsNull (ex.ParamName, "#A5");
430 // invalid keyword
431 try {
432 cn.ConnectionString = "invalidKeyword=10";
433 Assert.Fail ("#B1");
434 } catch (ArgumentException ex) {
435 // Keyword not supported: 'invalidkeyword'
436 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
437 Assert.IsNull (ex.InnerException, "#B3");
438 Assert.IsNotNull (ex.Message, "#B4");
439 Assert.IsTrue (ex.Message.IndexOf ("'invalidkeyword'") != -1, "#B5");
440 Assert.IsNull (ex.ParamName, "#B6");
444 [Test]
445 #if FEATURE_NO_BSD_SOCKETS
446 [ExpectedException (typeof (PlatformNotSupportedException))]
447 #endif
448 public void CreateCommand ()
450 SqlConnection cn = new SqlConnection ();
451 SqlCommand cmd = cn.CreateCommand ();
452 Assert.IsNotNull (cmd, "#1");
453 Assert.AreEqual (string.Empty, cmd.CommandText, "#2");
454 Assert.AreEqual (30, cmd.CommandTimeout, "#3");
455 Assert.AreEqual (CommandType.Text, cmd.CommandType, "#4");
456 Assert.AreSame (cn, cmd.Connection, "#5");
457 Assert.IsNull (cmd.Container, "#6");
458 Assert.IsTrue (cmd.DesignTimeVisible, "#7");
459 Assert.IsNull (cmd.Notification, "#8");
460 Assert.IsTrue (cmd.NotificationAutoEnlist, "#9");
461 Assert.IsNotNull (cmd.Parameters, "#10");
462 Assert.AreEqual (0, cmd.Parameters.Count, "#11");
463 Assert.IsNull (cmd.Site, "#12");
464 Assert.IsNull (cmd.Transaction, "#13");
465 Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#14");
468 [Test]
469 #if FEATURE_NO_BSD_SOCKETS
470 [ExpectedException (typeof (PlatformNotSupportedException))]
471 #endif
472 public void Dispose ()
474 SqlConnection cn = new SqlConnection ("Server=SQLSRV;Database=master;Timeout=25;Packet Size=512;Workstation ID=DUMMY");
475 cn.Dispose ();
477 Assert.AreEqual (string.Empty, cn.ConnectionString, "#1");
478 Assert.AreEqual (15, cn.ConnectionTimeout, "#2");
479 Assert.AreEqual (string.Empty, cn.Database, "#3");
480 Assert.AreEqual (string.Empty, cn.DataSource, "#4");
481 Assert.AreEqual (8000, cn.PacketSize, "#5");
482 Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#6");
483 Assert.AreEqual (ConnectionState.Closed, cn.State, "#7");
484 cn.Dispose ();
486 cn = new SqlConnection ();
487 cn.Dispose ();
490 [Test]
491 #if FEATURE_NO_BSD_SOCKETS
492 [ExpectedException (typeof (PlatformNotSupportedException))]
493 #endif
494 public void GetSchema_Connection_Closed ()
496 SqlConnection cn = new SqlConnection ();
498 try {
499 cn.GetSchema ();
500 Assert.Fail ("#A1");
501 } catch (InvalidOperationException ex) {
502 // Invalid operation. The connection is closed
503 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
504 Assert.IsNull (ex.InnerException, "#B3");
505 Assert.IsNotNull (ex.Message, "#B4");
508 try {
509 cn.GetSchema ("Tables");
510 Assert.Fail ("#B1");
511 } catch (InvalidOperationException ex) {
512 // Invalid operation. The connection is closed
513 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
514 Assert.IsNull (ex.InnerException, "#B3");
515 Assert.IsNotNull (ex.Message, "#B4");
518 try {
519 cn.GetSchema ((string) null);
520 Assert.Fail ("#C1");
521 } catch (InvalidOperationException ex) {
522 // Invalid operation. The connection is closed
523 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
524 Assert.IsNull (ex.InnerException, "#C3");
525 Assert.IsNotNull (ex.Message, "#C4");
528 try {
529 cn.GetSchema ("Tables", new string [] { "master" });
530 Assert.Fail ("#D1");
531 } catch (InvalidOperationException ex) {
532 // Invalid operation. The connection is closed
533 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
534 Assert.IsNull (ex.InnerException, "#D3");
535 Assert.IsNotNull (ex.Message, "#D4");
538 try {
539 cn.GetSchema ((string) null, new string [] { "master" });
540 Assert.Fail ("#E1");
541 } catch (InvalidOperationException ex) {
542 // Invalid operation. The connection is closed
543 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
544 Assert.IsNull (ex.InnerException, "#E3");
545 Assert.IsNotNull (ex.Message, "#E4");
548 try {
549 cn.GetSchema ("Tables", (string []) null);
550 Assert.Fail ("#F1");
551 } catch (InvalidOperationException ex) {
552 // Invalid operation. The connection is closed
553 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F2");
554 Assert.IsNull (ex.InnerException, "#F3");
555 Assert.IsNotNull (ex.Message, "#F4");
558 try {
559 cn.GetSchema ((string) null, (string []) null);
560 Assert.Fail ("#G1");
561 } catch (InvalidOperationException ex) {
562 // Invalid operation. The connection is closed
563 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#G2");
564 Assert.IsNull (ex.InnerException, "#G3");
565 Assert.IsNotNull (ex.Message, "#G4");
569 [Test]
570 #if FEATURE_NO_BSD_SOCKETS
571 [ExpectedException (typeof (PlatformNotSupportedException))]
572 #endif
573 public void ConnectionString_AsynchronousProcessing ()
575 SqlConnection cn = new SqlConnection ();
576 cn.ConnectionString = "Asynchronous Processing=False";
577 cn.ConnectionString = "Async=True";
580 [Test]
581 #if FEATURE_NO_BSD_SOCKETS
582 [ExpectedException (typeof (PlatformNotSupportedException))]
583 #endif
584 public void ConnectionString_ConnectTimeout ()
586 SqlConnection cn = new SqlConnection ();
587 cn.ConnectionString = "Connection Timeout=45";
588 Assert.AreEqual (45, cn.ConnectionTimeout, "#1");
589 cn.ConnectionString = "Connect Timeout=40";
590 Assert.AreEqual (40, cn.ConnectionTimeout, "#2");
591 cn.ConnectionString = "Timeout=";
592 Assert.AreEqual (15, cn.ConnectionTimeout, "#3");
593 cn.ConnectionString = "Timeout=2147483647";
594 Assert.AreEqual (int.MaxValue, cn.ConnectionTimeout, "#4");
595 cn.ConnectionString = "Timeout=0";
596 Assert.AreEqual (0, cn.ConnectionTimeout, "#5");
599 [Test]
600 #if FEATURE_NO_BSD_SOCKETS
601 [ExpectedException (typeof (PlatformNotSupportedException))]
602 #endif
603 public void ConnectionString_ConnectTimeout_Invalid ()
605 SqlConnection cn = new SqlConnection ();
607 // negative number
608 try {
609 cn.ConnectionString = "Connection timeout=-1";
610 Assert.Fail ("#A1");
611 } catch (ArgumentException ex) {
612 // Invalid value for key 'connect timeout'
613 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
614 Assert.IsNull (ex.InnerException, "#A3");
615 Assert.IsNotNull (ex.Message, "#A4");
616 Assert.IsTrue (ex.Message.IndexOf ("'connect timeout'") != -1, "#A5:" + ex.Message);
617 Assert.IsNull (ex.ParamName, "#A6");
620 // invalid number
621 try {
622 cn.ConnectionString = "connect Timeout=BB";
623 Assert.Fail ("#B1");
624 } catch (ArgumentException ex) {
625 // Invalid value for key 'connect timeout'
626 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
627 Assert.IsNotNull (ex.InnerException, "#B3");
628 Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#B4");
629 Assert.IsNotNull (ex.Message, "#B5");
630 Assert.IsTrue (ex.Message.IndexOf ("'connect timeout'") != -1, "#B6:" + ex.Message);
631 Assert.IsNull (ex.ParamName, "#B7");
633 // Input string was not in a correct format
634 FormatException fe = (FormatException) ex.InnerException;
635 Assert.IsNull (fe.InnerException, "#B8");
636 Assert.IsNotNull (fe.Message, "#B9");
639 // overflow
640 try {
641 cn.ConnectionString = "timeout=2147483648";
642 Assert.Fail ("#C1");
643 } catch (ArgumentException ex) {
644 // Invalid value for key 'connect timeout'
645 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
646 Assert.IsNotNull (ex.InnerException, "#C3");
647 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#C4");
648 Assert.IsNotNull (ex.Message, "#C5");
649 Assert.IsTrue (ex.Message.IndexOf ("'connect timeout'") != -1, "#C6:" + ex.Message);
650 Assert.IsNull (ex.ParamName, "#C7");
652 // Value was either too large or too small for an Int32
653 OverflowException oe = (OverflowException) ex.InnerException;
654 Assert.IsNull (oe.InnerException, "#C8");
655 Assert.IsNotNull (oe.Message, "#C9");
659 [Test]
660 #if FEATURE_NO_BSD_SOCKETS
661 [ExpectedException (typeof (PlatformNotSupportedException))]
662 #endif
663 public void ConnectionString_Database_Synonyms ()
665 SqlConnection cn = null;
667 cn = new SqlConnection ();
668 cn.ConnectionString = "Initial Catalog=db";
669 Assert.AreEqual ("db", cn.Database);
671 cn = new SqlConnection ();
672 cn.ConnectionString = "Database=db";
673 Assert.AreEqual ("db", cn.Database);
676 [Test]
677 #if FEATURE_NO_BSD_SOCKETS
678 [ExpectedException (typeof (PlatformNotSupportedException))]
679 #endif
680 public void ConnectionString_DataSource_Synonyms ()
682 SqlConnection cn = null;
684 cn = new SqlConnection ();
685 cn.ConnectionString = "Data Source=server";
686 Assert.AreEqual ("server", cn.DataSource);
688 cn = new SqlConnection ();
689 cn.ConnectionString = "addr=server";
690 Assert.AreEqual ("server", cn.DataSource);
692 cn = new SqlConnection ();
693 cn.ConnectionString = "address=server";
694 Assert.AreEqual ("server", cn.DataSource);
696 cn = new SqlConnection ();
697 cn.ConnectionString = "network address=server";
698 Assert.AreEqual ("server", cn.DataSource);
700 cn = new SqlConnection ();
701 cn.ConnectionString = "server=server";
702 Assert.AreEqual ("server", cn.DataSource);
705 [Test]
706 #if FEATURE_NO_BSD_SOCKETS
707 [ExpectedException (typeof (PlatformNotSupportedException))]
708 #endif
709 public void ConnectionString_MaxPoolSize ()
711 SqlConnection cn = new SqlConnection ();
712 cn.ConnectionString = "Max Pool Size=2147483647";
713 cn.ConnectionString = "Max Pool Size=1";
714 cn.ConnectionString = "Max Pool Size=500";
717 [Test]
718 #if FEATURE_NO_BSD_SOCKETS
719 [ExpectedException (typeof (PlatformNotSupportedException))]
720 #endif
721 public void ConnectionString_MaxPoolSize_Invalid ()
723 SqlConnection cn = new SqlConnection ();
725 // negative number
726 try {
727 cn.ConnectionString = "Max Pool Size=-1";
728 Assert.Fail ("#A1");
729 } catch (ArgumentException ex) {
730 // Invalid value for key 'max pool size'
731 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
732 Assert.IsNull (ex.InnerException, "#A3");
733 Assert.IsNotNull (ex.Message, "#A4");
734 Assert.IsTrue (ex.Message.IndexOf ("'max pool size'") != -1, "#A5:" + ex.Message);
735 Assert.IsNull (ex.ParamName, "#A6");
738 // invalid number
739 try {
740 cn.ConnectionString = "max Pool size=BB";
741 Assert.Fail ("#B1");
742 } catch (ArgumentException ex) {
743 // Invalid value for key 'max pool size'
744 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
745 Assert.IsNotNull (ex.InnerException, "#B3");
746 Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#B4");
747 Assert.IsNotNull (ex.Message, "#B5");
748 Assert.IsTrue (ex.Message.IndexOf ("'max pool size'") != -1, "#B6:" + ex.Message);
749 Assert.IsNull (ex.ParamName, "#B7");
751 // Input string was not in a correct format
752 FormatException fe = (FormatException) ex.InnerException;
753 Assert.IsNull (fe.InnerException, "#B8");
754 Assert.IsNotNull (fe.Message, "#B9");
757 // overflow
758 try {
759 cn.ConnectionString = "max pool size=2147483648";
760 Assert.Fail ("#C1");
761 } catch (ArgumentException ex) {
762 // Invalid value for key 'max pool size'
763 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
764 Assert.IsNotNull (ex.InnerException, "#C3");
765 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#C4");
766 Assert.IsNotNull (ex.Message, "#C5");
767 Assert.IsTrue (ex.Message.IndexOf ("'max pool size'") != -1, "#C6:" + ex.Message);
768 Assert.IsNull (ex.ParamName, "#C7");
770 // Value was either too large or too small for an Int32
771 OverflowException oe = (OverflowException) ex.InnerException;
772 Assert.IsNull (oe.InnerException, "#C8");
773 Assert.IsNotNull (oe.Message, "#C9");
776 // less than minimum (1)
777 try {
778 cn.ConnectionString = "Min Pool Size=0;Max Pool Size=0";
779 Assert.Fail ("#D1");
780 } catch (ArgumentException ex) {
781 // Invalid value for key 'max pool size'
782 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#D2");
783 Assert.IsNull (ex.InnerException, "#D3");
784 Assert.IsNotNull (ex.Message, "#D4");
785 Assert.IsTrue (ex.Message.IndexOf ("'max pool size'") != -1, "#D5:" + ex.Message);
786 Assert.IsNull (ex.ParamName, "#D6");
789 // less than min pool size
790 try {
791 cn.ConnectionString = "Min Pool Size=5;Max Pool Size=4";
792 Assert.Fail ("#E1");
793 } catch (ArgumentException ex) {
794 // Invalid min or max pool size values, min
795 // pool size cannot be greater than the max
796 // pool size
797 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#E2");
798 Assert.IsNull (ex.InnerException, "#E3");
799 Assert.IsNotNull (ex.Message, "#E4");
800 Assert.IsNull (ex.ParamName, "#E5");
804 [Test]
805 #if FEATURE_NO_BSD_SOCKETS
806 [ExpectedException (typeof (PlatformNotSupportedException))]
807 #endif
808 public void ConnectionString_MinPoolSize ()
810 SqlConnection cn = new SqlConnection ();
811 cn.ConnectionString = "min Pool size=0";
812 cn.ConnectionString = "Min Pool size=100";
813 cn.ConnectionString = "Min Pool Size=2147483647;Max Pool Size=2147483647";
816 [Test]
817 #if FEATURE_NO_BSD_SOCKETS
818 [ExpectedException (typeof (PlatformNotSupportedException))]
819 #endif
820 public void ConnectionString_MinPoolSize_Invalid ()
822 SqlConnection cn = new SqlConnection ();
824 // negative number
825 try {
826 cn.ConnectionString = "Min Pool Size=-1";
827 Assert.Fail ("#A1");
828 } catch (ArgumentException ex) {
829 // Invalid value for key 'min pool size'
830 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
831 Assert.IsNull (ex.InnerException, "#A3");
832 Assert.IsNotNull (ex.Message, "#A4");
833 Assert.IsTrue (ex.Message.IndexOf ("'min pool size'") != -1, "#A5:" + ex.Message);
834 Assert.IsNull (ex.ParamName, "#A6");
837 // invalid number
838 try {
839 cn.ConnectionString = "min Pool size=BB";
840 Assert.Fail ("#B1");
841 } catch (ArgumentException ex) {
842 // Invalid value for key 'min pool size'
843 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
844 Assert.IsNotNull (ex.InnerException, "#B3");
845 Assert.AreEqual (typeof (FormatException), ex.InnerException.GetType (), "#B4");
846 Assert.IsNotNull (ex.Message, "#B5");
847 Assert.IsTrue (ex.Message.IndexOf ("'min pool size'") != -1, "#B6:" + ex.Message);
848 Assert.IsNull (ex.ParamName, "#B7");
850 // Input string was not in a correct format
851 FormatException fe = (FormatException) ex.InnerException;
852 Assert.IsNull (fe.InnerException, "#B8");
853 Assert.IsNotNull (fe.Message, "#B9");
856 // overflow
857 try {
858 cn.ConnectionString = "min pool size=2147483648";
859 Assert.Fail ("#C1");
860 } catch (ArgumentException ex) {
861 // Invalid value for key 'min pool size'
862 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
863 Assert.IsNotNull (ex.InnerException, "#C3");
864 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#C4");
865 Assert.IsNotNull (ex.Message, "#C5");
866 Assert.IsTrue (ex.Message.IndexOf ("'min pool size'") != -1, "#C6:" + ex.Message);
867 Assert.IsNull (ex.ParamName, "#C7");
869 // Value was either too large or too small for an Int32
870 OverflowException oe = (OverflowException) ex.InnerException;
871 Assert.IsNull (oe.InnerException, "#C8");
872 Assert.IsNotNull (oe.Message, "#C9");
876 [Test]
877 #if FEATURE_NO_BSD_SOCKETS
878 [ExpectedException (typeof (PlatformNotSupportedException))]
879 #endif
880 public void ConnectionString_MultipleActiveResultSets ()
882 SqlConnection cn = new SqlConnection ();
883 cn.ConnectionString = "MultipleActiveResultSets=true";
886 [Test]
887 #if FEATURE_NO_BSD_SOCKETS
888 [ExpectedException (typeof (PlatformNotSupportedException))]
889 #endif
890 public void ConnectionString_MultipleActiveResultSets_Invalid ()
892 SqlConnection cn = new SqlConnection ();
893 try {
894 cn.ConnectionString = "MultipleActiveResultSets=1";
895 Assert.Fail ("#1");
896 } catch (ArgumentException ex) {
897 // Invalid value for key 'multipleactiveresultsets'
898 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
899 Assert.IsNull (ex.InnerException, "#3");
900 Assert.IsNotNull (ex.Message, "#4");
901 Assert.IsTrue (ex.Message.IndexOf ("'multipleactiveresultsets'") != -1, "#5:" + ex.Message);
902 Assert.IsNull (ex.ParamName, "#6");
906 [Test]
907 #if FEATURE_NO_BSD_SOCKETS
908 [ExpectedException (typeof (PlatformNotSupportedException))]
909 #endif
910 public void ConnectionString_NetworkLibrary_Synonyms ()
912 SqlConnection cn = new SqlConnection ();
913 cn.ConnectionString = "Net=DBMSSOCN";
914 cn.ConnectionString = "Network=DBMSSOCN";
915 cn.ConnectionString = "Network library=DBMSSOCN";
918 [Test]
919 #if FEATURE_NO_BSD_SOCKETS
920 [ExpectedException (typeof (PlatformNotSupportedException))]
921 #endif
922 public void ConnectionString_PacketSize ()
924 SqlConnection cn = new SqlConnection ();
925 cn.ConnectionString = "Packet Size=1024";
926 Assert.AreEqual (1024, cn.PacketSize, "#1");
927 cn.ConnectionString = "packet SizE=533";
928 Assert.AreEqual (533, cn.PacketSize, "#2");
929 cn.ConnectionString = "packet SizE=512";
930 Assert.AreEqual (512, cn.PacketSize, "#3");
931 cn.ConnectionString = "packet SizE=32768";
932 Assert.AreEqual (32768, cn.PacketSize, "#4");
933 cn.ConnectionString = "packet Size=";
934 Assert.AreEqual (8000, cn.PacketSize, "#5");
937 [Test]
938 #if FEATURE_NO_BSD_SOCKETS
939 [ExpectedException (typeof (PlatformNotSupportedException))]
940 #endif
941 public void ConnectionString_PacketSize_Invalid ()
943 SqlConnection cn = new SqlConnection ();
945 // invalid packet size (< minimum)
946 try {
947 cn.ConnectionString = "Packet Size=511";
948 Assert.Fail ("#A1");
949 } catch (ArgumentException ex) {
950 // Invalid 'Packet Size'. The value must be an
951 // integer >= 512 and <= 32768
952 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
953 Assert.IsNull (ex.InnerException, "#A3");
954 Assert.IsNotNull (ex.Message, "#A4");
955 Assert.IsTrue (ex.Message.IndexOf ("'Packet Size'") != -1, "#A5:" + ex.Message);
956 Assert.IsNull (ex.ParamName, "#A6");
959 // invalid packet size (> maximum)
960 try {
961 cn.ConnectionString = "packet SIze=32769";
962 Assert.Fail ("#B1");
963 } catch (ArgumentException ex) {
964 // Invalid 'Packet Size'. The value must be an
965 // integer >= 512 and <= 32768
966 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
967 Assert.IsNull (ex.InnerException, "#B3");
968 Assert.IsNotNull (ex.Message, "#B4");
969 Assert.IsTrue (ex.Message.IndexOf ("'Packet Size'") != -1, "#B5:" + ex.Message);
970 Assert.IsNull (ex.ParamName, "#B6");
973 // overflow
974 try {
975 cn.ConnectionString = "packet SIze=2147483648";
976 Assert.Fail ("#C1");
977 } catch (ArgumentException ex) {
978 // Invalid value for key 'packet size'
979 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#C2");
980 Assert.IsNotNull (ex.InnerException, "#C3");
981 Assert.AreEqual (typeof (OverflowException), ex.InnerException.GetType (), "#C4");
982 Assert.IsNotNull (ex.Message, "#C5");
983 Assert.IsTrue (ex.Message.IndexOf ("'packet size'") != -1, "#C6:" + ex.Message);
984 Assert.IsNull (ex.ParamName, "#C7");
986 // Value was either too large or too small for an Int32
987 OverflowException oe = (OverflowException) ex.InnerException;
988 Assert.IsNull (oe.InnerException, "#C8");
989 Assert.IsNotNull (oe.Message, "#C9");
993 [Test]
994 #if FEATURE_NO_BSD_SOCKETS
995 [ExpectedException (typeof (PlatformNotSupportedException))]
996 #endif
997 public void ConnectionString_Password_Synonyms ()
999 SqlConnection cn = new SqlConnection ();
1000 cn.ConnectionString = "Password=scrambled";
1001 cn.ConnectionString = "Pwd=scrambled";
1004 [Test]
1005 #if FEATURE_NO_BSD_SOCKETS
1006 [ExpectedException (typeof (PlatformNotSupportedException))]
1007 #endif
1008 public void ConnectionString_PersistSecurityInfo_Synonyms ()
1010 SqlConnection cn = new SqlConnection ();
1011 cn.ConnectionString = "Persist Security Info=true";
1012 cn.ConnectionString = "PersistSecurityInfo=true";
1015 [Test]
1016 #if FEATURE_NO_BSD_SOCKETS
1017 [ExpectedException (typeof (PlatformNotSupportedException))]
1018 #endif
1019 public void ConnectionString_UserID_Synonyms ()
1021 SqlConnection cn = new SqlConnection ();
1022 cn.ConnectionString = "User Id=test";
1023 cn.ConnectionString = "User=test";
1024 cn.ConnectionString = "Uid=test";
1027 [Test]
1028 #if FEATURE_NO_BSD_SOCKETS
1029 [ExpectedException (typeof (PlatformNotSupportedException))]
1030 #endif
1031 public void ConnectionString_UserInstance ()
1033 SqlConnection cn = new SqlConnection ();
1034 cn.ConnectionString = "User Instance=true";
1037 [Test]
1038 #if FEATURE_NO_BSD_SOCKETS
1039 [ExpectedException (typeof (PlatformNotSupportedException))]
1040 #endif
1041 public void ConnectionString_UserInstance_Invalid ()
1043 SqlConnection cn = new SqlConnection ();
1044 try {
1045 cn.ConnectionString = "User Instance=1";
1046 Assert.Fail ("#1");
1047 } catch (ArgumentException ex) {
1048 // Invalid value for key 'user instance'
1049 Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
1050 Assert.IsNull (ex.InnerException, "#3");
1051 Assert.IsNotNull (ex.Message, "#4");
1052 Assert.IsTrue (ex.Message.IndexOf ("'user instance'") != -1, "#5:" + ex.Message);
1053 Assert.IsNull (ex.ParamName, "#6");
1057 [Test]
1058 #if FEATURE_NO_BSD_SOCKETS
1059 [ExpectedException (typeof (PlatformNotSupportedException))]
1060 #endif
1061 public void ConnectionString_OtherKeywords ()
1063 SqlConnection cn = new SqlConnection ();
1064 cn.ConnectionString = "Application Name=test";
1065 cn.ConnectionString = "App=test";
1066 cn.ConnectionString = "Connection Reset=true";
1067 cn.ConnectionString = "Current Language=test";
1068 cn.ConnectionString = "Language=test";
1069 cn.ConnectionString = "Encrypt=false";
1070 //cn.ConnectionString = "Encrypt=true";
1071 //cn.ConnectionString = "Enlist=false";
1072 cn.ConnectionString = "Enlist=true";
1073 cn.ConnectionString = "Integrated Security=true";
1074 cn.ConnectionString = "Trusted_connection=true";
1075 cn.ConnectionString = "Max Pool Size=10";
1076 cn.ConnectionString = "Min Pool Size=10";
1077 cn.ConnectionString = "Pooling=true";
1078 cn.ConnectionString = "attachdbfilename=dunno";
1079 cn.ConnectionString = "extended properties=dunno";
1080 cn.ConnectionString = "initial file name=dunno";
1083 [Test]
1084 #if FEATURE_NO_BSD_SOCKETS
1085 [ExpectedException (typeof (PlatformNotSupportedException))]
1086 #endif
1087 public void Open_ConnectionString_Empty ()
1089 SqlConnection cn = new SqlConnection ();
1090 cn.ConnectionString = string.Empty;
1092 try {
1093 cn.Open ();
1094 Assert.Fail ("#1");
1095 } catch (InvalidOperationException ex) {
1096 // The ConnectionString property has not been
1097 // initialized
1098 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1099 Assert.IsNull (ex.InnerException, "#3");
1100 Assert.IsNotNull (ex.Message, "#4");
1104 [Test]
1105 #if FEATURE_NO_BSD_SOCKETS
1106 [ExpectedException (typeof (PlatformNotSupportedException))]
1107 #endif
1108 public void Open_ConnectionString_Null ()
1110 SqlConnection cn = new SqlConnection ();
1111 cn.ConnectionString = null;
1113 try {
1114 cn.Open ();
1115 Assert.Fail ("#1");
1116 } catch (InvalidOperationException ex) {
1117 // The ConnectionString property has not been
1118 // initialized
1119 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1120 Assert.IsNull (ex.InnerException, "#3");
1121 Assert.IsNotNull (ex.Message, "#4");
1125 [Test]
1126 #if FEATURE_NO_BSD_SOCKETS
1127 [ExpectedException (typeof (PlatformNotSupportedException))]
1128 #endif
1129 public void Open_ConnectionString_Whitespace ()
1131 SqlConnection cn = new SqlConnection ();
1132 cn.ConnectionString = " ";
1134 try {
1135 cn.Open ();
1136 Assert.Fail ("#1");
1137 } catch (InvalidOperationException ex) {
1138 // The ConnectionString property has not been
1139 // initialized
1140 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
1141 Assert.IsNull (ex.InnerException, "#3");
1142 Assert.IsNotNull (ex.Message, "#4");
1146 [Test]
1147 #if FEATURE_NO_BSD_SOCKETS
1148 [ExpectedException (typeof (PlatformNotSupportedException))]
1149 #endif
1150 public void ServerVersion_Connection_Closed ()
1152 SqlConnection cn = new SqlConnection ();
1153 try {
1154 Assert.Fail ("#A1:" + cn.ServerVersion);
1155 } catch (InvalidOperationException ex) {
1156 // Invalid operation. The connection is closed
1157 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
1158 Assert.IsNull (ex.InnerException, "#A3");
1159 Assert.IsNotNull (ex.Message, "#A4");
1162 cn = new SqlConnection ("server=SQLSRV; database=Mono;");
1163 try {
1164 Assert.Fail ("#B1:" + cn.ServerVersion);
1165 } catch (InvalidOperationException ex) {
1166 // Invalid operation. The connection is closed
1167 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
1168 Assert.IsNull (ex.InnerException, "#B3");
1169 Assert.IsNotNull (ex.Message, "#B4");