2 // SqlConnectionTest.cs - NUnit Test Cases for testing the
5 // Gert Driesen (drieseng@users.sourceforge.net)
7 // Copyright (c) 2004 Novell Inc., and the individuals listed
8 // on the ChangeLog entries.
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.
32 using System
.Data
.SqlClient
;
34 using NUnit
.Framework
;
36 namespace MonoTests
.System
.Data
.SqlClient
39 public class SqlConnectionTest
41 [Test
] // SqlConnection ()
42 #if FEATURE_NO_BSD_SOCKETS
43 [ExpectedException (typeof (PlatformNotSupportedException
))]
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 // https://github.com/dotnet/corefx/issues/22871
60 //Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#11");
63 [Test
] // SqlConnection (string)
64 #if FEATURE_NO_BSD_SOCKETS
65 [ExpectedException (typeof (PlatformNotSupportedException
))]
67 public void Constructor2 ()
69 string connectionString
= "server=SQLSRV; database=Mono;";
71 SqlConnection cn
= new SqlConnection (connectionString
);
72 Assert
.AreEqual (connectionString
, cn
.ConnectionString
, "#A1");
73 Assert
.AreEqual (15, cn
.ConnectionTimeout
, "#A2");
74 Assert
.IsNull (cn
.Container
, "#A3");
75 Assert
.AreEqual ("Mono", cn
.Database
, "#A4");
76 Assert
.AreEqual ("SQLSRV", cn
.DataSource
, "#A5");
77 Assert
.IsFalse (cn
.FireInfoMessageEventOnUserErrors
, "#A6");
78 Assert
.AreEqual (8000, cn
.PacketSize
, "#A7");
79 Assert
.IsNull (cn
.Site
, "#A8");
80 Assert
.AreEqual (ConnectionState
.Closed
, cn
.State
, "#A9");
81 Assert
.IsFalse (cn
.StatisticsEnabled
, "#A10");
82 // https://github.com/dotnet/corefx/issues/22871
83 //Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#A11");
85 cn
= new SqlConnection ((string) null);
86 Assert
.AreEqual (string.Empty
, cn
.ConnectionString
, "#B1");
87 Assert
.AreEqual (15, cn
.ConnectionTimeout
, "#B2");
88 Assert
.IsNull (cn
.Container
, "#B3");
89 Assert
.AreEqual (string.Empty
, cn
.Database
, "#B4");
90 Assert
.AreEqual (string.Empty
, cn
.DataSource
, "#B5");
91 Assert
.IsFalse (cn
.FireInfoMessageEventOnUserErrors
, "#B6");
92 Assert
.AreEqual (8000, cn
.PacketSize
, "#B7");
93 Assert
.IsNull (cn
.Site
, "#B8");
94 Assert
.AreEqual (ConnectionState
.Closed
, cn
.State
, "#B9");
95 Assert
.IsFalse (cn
.StatisticsEnabled
, "#B10");
96 // https://github.com/dotnet/corefx/issues/22871
97 //Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#B11");
101 #if FEATURE_NO_BSD_SOCKETS
102 [ExpectedException (typeof (PlatformNotSupportedException
))]
104 public void Constructor2_ConnectionString_Invalid ()
107 new SqlConnection ("InvalidConnectionString");
109 } catch (ArgumentException ex
) {
110 // Format of the initialization string does
111 // not conform to specification starting at
113 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#A2");
114 Assert
.IsNull (ex
.InnerException
, "#A3");
115 Assert
.IsNotNull (ex
.Message
, "#A4");
116 Assert
.IsNull (ex
.ParamName
, "#A5");
121 new SqlConnection ("invalidKeyword=10");
123 } catch (ArgumentException ex
) {
124 // Keyword not supported: 'invalidkeyword'
125 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#B2");
126 Assert
.IsNull (ex
.InnerException
, "#B3");
127 Assert
.IsNotNull (ex
.Message
, "#B4");
128 Assert
.IsTrue (ex
.Message
.IndexOf ("'invalidkeyword'") != -1, "#B5");
129 Assert
.IsNull (ex
.ParamName
, "#B6");
132 // invalid packet size (< minimum)
134 new SqlConnection ("Packet Size=511");
136 } catch (ArgumentException ex
) {
137 // Invalid 'Packet Size'. The value must be an
138 // integer >= 512 and <= 32768
139 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#C2");
140 Assert
.IsNull (ex
.InnerException
, "#C3");
141 Assert
.IsNotNull (ex
.Message
, "#C4");
142 Assert
.IsNull (ex
.ParamName
, "#C5");
145 // invalid packet size (> maximum)
147 new SqlConnection ("Packet Size=32769");
149 } catch (ArgumentException ex
) {
150 // Invalid 'Packet Size'. The value must be an
151 // integer >= 512 and <= 32768
152 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#D2");
153 Assert
.IsNull (ex
.InnerException
, "#D3");
154 Assert
.IsNotNull (ex
.Message
, "#D4");
155 Assert
.IsNull (ex
.ParamName
, "#D5");
158 // negative connect timeout
160 new SqlConnection ("Connect Timeout=-1");
162 } catch (ArgumentException ex
) {
163 // Invalid value for key 'connect timeout'
164 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#E2");
165 Assert
.IsNull (ex
.InnerException
, "#E3");
166 Assert
.IsNotNull (ex
.Message
, "#E4");
167 Assert
.IsNull (ex
.ParamName
, "#E5");
170 // negative max pool size
172 new SqlConnection ("Max Pool Size=-1");
174 } catch (ArgumentException ex
) {
175 // Invalid value for key 'max pool size'
176 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#F2");
177 Assert
.IsNull (ex
.InnerException
, "#F3");
178 Assert
.IsNotNull (ex
.Message
, "#F4");
179 Assert
.IsNull (ex
.ParamName
, "#F5");
182 // negative min pool size
184 new SqlConnection ("Min Pool Size=-1");
186 } catch (ArgumentException ex
) {
187 // Invalid value for key 'min pool size'
188 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#G2");
189 Assert
.IsNull (ex
.InnerException
, "#G3");
190 Assert
.IsNotNull (ex
.Message
, "#G4");
191 Assert
.IsNull (ex
.ParamName
, "#G5");
196 #if FEATURE_NO_BSD_SOCKETS
197 [ExpectedException (typeof (PlatformNotSupportedException
))]
199 public void BeginTransaction_Connection_Closed ()
201 SqlConnection cn
= new SqlConnection ();
204 cn
.BeginTransaction ();
206 } catch (InvalidOperationException ex
) {
207 // Invalid operation. The connection is closed
208 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#A2");
209 Assert
.IsNull (ex
.InnerException
, "#A3");
210 Assert
.IsNotNull (ex
.Message
, "#A4");
214 cn
.BeginTransaction ((IsolationLevel
) 666);
216 } catch (InvalidOperationException ex
) {
217 // Invalid operation. The connection is closed
218 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#B2");
219 Assert
.IsNull (ex
.InnerException
, "#B3");
220 Assert
.IsNotNull (ex
.Message
, "#B4");
224 cn
.BeginTransaction (IsolationLevel
.Serializable
);
226 } catch (InvalidOperationException ex
) {
227 // Invalid operation. The connection is closed
228 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#C2");
229 Assert
.IsNull (ex
.InnerException
, "#C3");
230 Assert
.IsNotNull (ex
.Message
, "#C4");
234 cn
.BeginTransaction ("trans");
236 } catch (InvalidOperationException ex
) {
237 // Invalid operation. The connection is closed
238 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#D2");
239 Assert
.IsNull (ex
.InnerException
, "#D3");
240 Assert
.IsNotNull (ex
.Message
, "#D4");
244 cn
.BeginTransaction ((IsolationLevel
) 666, "trans");
246 } catch (InvalidOperationException ex
) {
247 // Invalid operation. The connection is closed
248 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#E2");
249 Assert
.IsNull (ex
.InnerException
, "#E3");
250 Assert
.IsNotNull (ex
.Message
, "#E4");
254 cn
.BeginTransaction (IsolationLevel
.Serializable
, "trans");
256 } catch (InvalidOperationException ex
) {
257 // Invalid operation. The connection is closed
258 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#F2");
259 Assert
.IsNull (ex
.InnerException
, "#F3");
260 Assert
.IsNotNull (ex
.Message
, "#F4");
265 #if FEATURE_NO_BSD_SOCKETS
266 [ExpectedException (typeof (PlatformNotSupportedException
))]
268 public void ChangeDatabase_Connection_Closed ()
270 SqlConnection cn
= new SqlConnection ();
271 cn
.ConnectionString
= "server=SQLSRV";
274 cn
.ChangeDatabase ("database");
276 } catch (InvalidOperationException ex
) {
277 // Invalid operation. The connection is closed
278 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
279 Assert
.IsNull (ex
.InnerException
, "#3");
280 Assert
.IsNotNull (ex
.Message
, "#4");
285 [Category("NotWorking")] // https://github.com/dotnet/corefx/issues/11958
286 #if FEATURE_NO_BSD_SOCKETS
287 [ExpectedException (typeof (PlatformNotSupportedException
))]
289 public void ChangePassword_ConnectionString_Empty ()
292 SqlConnection
.ChangePassword (string.Empty
, "mono");
294 } catch (ArgumentNullException ex
) {
295 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#2");
296 Assert
.IsNull (ex
.InnerException
, "#3");
297 Assert
.IsNotNull (ex
.Message
, "#4");
298 Assert
.IsNotNull (ex
.ParamName
, "#5");
299 Assert
.IsTrue (ex
.ParamName
.IndexOf ("'connectionString'") != -1, "#6");
304 [Category("NotWorking")] // https://github.com/dotnet/corefx/issues/11958
305 #if FEATURE_NO_BSD_SOCKETS
306 [ExpectedException (typeof (PlatformNotSupportedException
))]
308 public void ChangePassword_ConnectionString_Null ()
311 SqlConnection
.ChangePassword ((string) null, "mono");
313 } catch (ArgumentNullException ex
) {
314 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#2");
315 Assert
.IsNull (ex
.InnerException
, "#3");
316 Assert
.IsNotNull (ex
.Message
, "#4");
317 Assert
.IsNotNull (ex
.ParamName
, "#5");
318 Assert
.IsTrue (ex
.ParamName
.IndexOf ("'connectionString'") != -1, "#6");
323 #if FEATURE_NO_BSD_SOCKETS
324 [ExpectedException (typeof (PlatformNotSupportedException
))]
326 public void ChangePassword_NewPassword_Empty ()
329 SqlConnection
.ChangePassword ("server=SQLSRV", string.Empty
);
331 } catch (ArgumentNullException ex
) {
332 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#2");
333 Assert
.IsNull (ex
.InnerException
, "#3");
334 Assert
.IsNotNull (ex
.Message
, "#4");
335 Assert
.IsNotNull (ex
.ParamName
, "#5");
336 Assert
.IsTrue (ex
.ParamName
.IndexOf ("'newPassword'") != -1, "#6");
341 [Category("NotWorking")] // https://github.com/dotnet/corefx/issues/11958
342 #if FEATURE_NO_BSD_SOCKETS
343 [ExpectedException (typeof (PlatformNotSupportedException
))]
345 public void ChangePassword_NewPassword_ExceedMaxLength ()
348 SqlConnection
.ChangePassword ("server=SQLSRV",
349 new string ('d', 129));
351 } catch (ArgumentException ex
) {
352 // The length of argument 'newPassword' exceeds
353 // it's limit of '128'
354 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#2");
355 Assert
.IsNull (ex
.InnerException
, "#3");
356 Assert
.IsNotNull (ex
.Message
, "#4");
357 Assert
.IsTrue (ex
.Message
.IndexOf ("'newPassword'") != -1, "#5");
358 Assert
.IsTrue (ex
.Message
.IndexOf ("128") != -1, "#6");
359 Assert
.IsNull (ex
.ParamName
, "#7");
364 [Category("NotWorking")] // https://github.com/dotnet/corefx/issues/11958
365 #if FEATURE_NO_BSD_SOCKETS
366 [ExpectedException (typeof (PlatformNotSupportedException
))]
368 public void ChangePassword_NewPassword_Null ()
371 SqlConnection
.ChangePassword ("server=SQLSRV", (string) null);
373 } catch (ArgumentNullException ex
) {
374 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#2");
375 Assert
.IsNull (ex
.InnerException
, "#3");
376 Assert
.IsNotNull (ex
.Message
, "#4");
377 Assert
.IsNotNull (ex
.ParamName
, "#5");
378 Assert
.IsTrue (ex
.ParamName
.IndexOf ("'newPassword'") != -1, "#6");
383 #if FEATURE_NO_BSD_SOCKETS
384 [ExpectedException (typeof (PlatformNotSupportedException
))]
386 public void ClearPool_Connection_Null ()
389 SqlConnection
.ClearPool ((SqlConnection
) null);
391 } catch (ArgumentNullException ex
) {
392 Assert
.AreEqual (typeof (ArgumentNullException
), ex
.GetType (), "#2");
393 Assert
.IsNull (ex
.InnerException
, "#3");
394 Assert
.IsNotNull (ex
.Message
, "#4");
395 Assert
.AreEqual ("connection", ex
.ParamName
, "#5");
400 #if FEATURE_NO_BSD_SOCKETS
401 [ExpectedException (typeof (PlatformNotSupportedException
))]
403 public void ConnectionString ()
405 SqlConnection cn
= new SqlConnection ();
406 cn
.ConnectionString
= "server=SQLSRV";
407 Assert
.AreEqual ("server=SQLSRV", cn
.ConnectionString
, "#1");
408 cn
.ConnectionString
= null;
409 Assert
.AreEqual (string.Empty
, cn
.ConnectionString
, "#2");
410 cn
.ConnectionString
= "server=SQLSRV";
411 Assert
.AreEqual ("server=SQLSRV", cn
.ConnectionString
, "#3");
412 cn
.ConnectionString
= string.Empty
;
413 Assert
.AreEqual (string.Empty
, cn
.ConnectionString
, "#4");
417 #if FEATURE_NO_BSD_SOCKETS
418 [ExpectedException (typeof (PlatformNotSupportedException
))]
420 public void ConnectionString_Value_Invalid ()
422 SqlConnection cn
= new SqlConnection ();
425 cn
.ConnectionString
= "InvalidConnectionString";
427 } catch (ArgumentException ex
) {
428 // Format of the initialization string does
429 // not conform to specification starting at
431 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#A2");
432 Assert
.IsNull (ex
.InnerException
, "#A3");
433 Assert
.IsNotNull (ex
.Message
, "#A4");
434 Assert
.IsNull (ex
.ParamName
, "#A5");
439 cn
.ConnectionString
= "invalidKeyword=10";
441 } catch (ArgumentException ex
) {
442 // Keyword not supported: 'invalidkeyword'
443 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#B2");
444 Assert
.IsNull (ex
.InnerException
, "#B3");
445 Assert
.IsNotNull (ex
.Message
, "#B4");
446 Assert
.IsTrue (ex
.Message
.IndexOf ("'invalidkeyword'") != -1, "#B5");
447 Assert
.IsNull (ex
.ParamName
, "#B6");
452 #if FEATURE_NO_BSD_SOCKETS
453 [ExpectedException (typeof (PlatformNotSupportedException
))]
455 public void CreateCommand ()
457 SqlConnection cn
= new SqlConnection ();
458 SqlCommand cmd
= cn
.CreateCommand ();
459 Assert
.IsNotNull (cmd
, "#1");
460 Assert
.AreEqual (string.Empty
, cmd
.CommandText
, "#2");
461 Assert
.AreEqual (30, cmd
.CommandTimeout
, "#3");
462 Assert
.AreEqual (CommandType
.Text
, cmd
.CommandType
, "#4");
463 Assert
.AreSame (cn
, cmd
.Connection
, "#5");
464 Assert
.IsNull (cmd
.Container
, "#6");
465 Assert
.IsTrue (cmd
.DesignTimeVisible
, "#7");
466 Assert
.IsNull (cmd
.Notification
, "#8");
467 // not implemented in corefx yet
468 // Assert.IsTrue (cmd.NotificationAutoEnlist, "#9");
469 Assert
.IsNotNull (cmd
.Parameters
, "#10");
470 Assert
.AreEqual (0, cmd
.Parameters
.Count
, "#11");
471 Assert
.IsNull (cmd
.Site
, "#12");
472 Assert
.IsNull (cmd
.Transaction
, "#13");
473 Assert
.AreEqual (UpdateRowSource
.Both
, cmd
.UpdatedRowSource
, "#14");
477 #if FEATURE_NO_BSD_SOCKETS
478 [ExpectedException (typeof (PlatformNotSupportedException
))]
480 public void Dispose ()
482 SqlConnection cn
= new SqlConnection ("Server=SQLSRV;Database=master;Timeout=25;Packet Size=512;Workstation ID=DUMMY");
485 Assert
.AreEqual (string.Empty
, cn
.ConnectionString
, "#1");
486 Assert
.AreEqual (15, cn
.ConnectionTimeout
, "#2");
487 Assert
.AreEqual (string.Empty
, cn
.Database
, "#3");
488 Assert
.AreEqual (string.Empty
, cn
.DataSource
, "#4");
489 Assert
.AreEqual (8000, cn
.PacketSize
, "#5");
490 // https://github.com/dotnet/corefx/issues/22871
491 // Assert.IsTrue (string.Compare (Environment.MachineName, cn.WorkstationId, true) == 0, "#6");
492 Assert
.AreEqual (ConnectionState
.Closed
, cn
.State
, "#7");
495 cn
= new SqlConnection ();
500 [Category("NotWorking")] //https://github.com/dotnet/corefx/issues/22882
501 #if FEATURE_NO_BSD_SOCKETS
502 [ExpectedException (typeof (PlatformNotSupportedException
))]
504 public void GetSchema_Connection_Closed ()
506 SqlConnection cn
= new SqlConnection ();
511 } catch (InvalidOperationException ex
) {
512 // Invalid operation. The connection is closed
513 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#A2");
514 Assert
.IsNull (ex
.InnerException
, "#B3");
515 Assert
.IsNotNull (ex
.Message
, "#B4");
519 cn
.GetSchema ("Tables");
521 } catch (InvalidOperationException ex
) {
522 // Invalid operation. The connection is closed
523 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#B2");
524 Assert
.IsNull (ex
.InnerException
, "#B3");
525 Assert
.IsNotNull (ex
.Message
, "#B4");
529 cn
.GetSchema ((string) null);
531 } catch (InvalidOperationException ex
) {
532 // Invalid operation. The connection is closed
533 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#C2");
534 Assert
.IsNull (ex
.InnerException
, "#C3");
535 Assert
.IsNotNull (ex
.Message
, "#C4");
539 cn
.GetSchema ("Tables", new string [] { "master" }
);
541 } catch (InvalidOperationException ex
) {
542 // Invalid operation. The connection is closed
543 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#D2");
544 Assert
.IsNull (ex
.InnerException
, "#D3");
545 Assert
.IsNotNull (ex
.Message
, "#D4");
549 cn
.GetSchema ((string) null, new string [] { "master" }
);
551 } catch (InvalidOperationException ex
) {
552 // Invalid operation. The connection is closed
553 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#E2");
554 Assert
.IsNull (ex
.InnerException
, "#E3");
555 Assert
.IsNotNull (ex
.Message
, "#E4");
559 cn
.GetSchema ("Tables", (string []) null);
561 } catch (InvalidOperationException ex
) {
562 // Invalid operation. The connection is closed
563 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#F2");
564 Assert
.IsNull (ex
.InnerException
, "#F3");
565 Assert
.IsNotNull (ex
.Message
, "#F4");
569 cn
.GetSchema ((string) null, (string []) null);
571 } catch (InvalidOperationException ex
) {
572 // Invalid operation. The connection is closed
573 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#G2");
574 Assert
.IsNull (ex
.InnerException
, "#G3");
575 Assert
.IsNotNull (ex
.Message
, "#G4");
580 [Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
581 #if FEATURE_NO_BSD_SOCKETS
582 [ExpectedException (typeof (PlatformNotSupportedException
))]
584 public void ConnectionString_AsynchronousProcessing ()
586 SqlConnection cn
= new SqlConnection ();
587 cn
.ConnectionString
= "Asynchronous Processing=False";
588 cn
.ConnectionString
= "Async=True";
592 [Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22879
593 #if FEATURE_NO_BSD_SOCKETS
594 [ExpectedException (typeof (PlatformNotSupportedException
))]
596 public void ConnectionString_ConnectTimeout ()
598 SqlConnection cn
= new SqlConnection ();
599 cn
.ConnectionString
= "Connection Timeout=45";
600 Assert
.AreEqual (45, cn
.ConnectionTimeout
, "#1");
601 cn
.ConnectionString
= "Connect Timeout=40";
602 Assert
.AreEqual (40, cn
.ConnectionTimeout
, "#2");
603 cn
.ConnectionString
= "Timeout=";
604 Assert
.AreEqual (15, cn
.ConnectionTimeout
, "#3");
605 cn
.ConnectionString
= "Timeout=2147483647";
606 Assert
.AreEqual (int.MaxValue
, cn
.ConnectionTimeout
, "#4");
607 cn
.ConnectionString
= "Timeout=0";
608 Assert
.AreEqual (0, cn
.ConnectionTimeout
, "#5");
612 #if FEATURE_NO_BSD_SOCKETS
613 [ExpectedException (typeof (PlatformNotSupportedException
))]
615 public void ConnectionString_ConnectTimeout_Invalid ()
617 SqlConnection cn
= new SqlConnection ();
621 cn
.ConnectionString
= "Connection timeout=-1";
623 } catch (ArgumentException ex
) {
624 // Invalid value for key 'connect timeout'
625 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#A2");
626 Assert
.IsNull (ex
.InnerException
, "#A3");
627 Assert
.IsNotNull (ex
.Message
, "#A4");
628 Assert
.IsTrue (ex
.Message
.IndexOf ("'connect timeout'") != -1, "#A5:" + ex
.Message
);
629 Assert
.IsNull (ex
.ParamName
, "#A6");
634 cn
.ConnectionString
= "connect Timeout=BB";
636 } catch (ArgumentException ex
) {
637 // Invalid value for key 'connect timeout'
638 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#B2");
639 Assert
.IsNotNull (ex
.InnerException
, "#B3");
640 Assert
.AreEqual (typeof (FormatException
), ex
.InnerException
.GetType (), "#B4");
641 Assert
.IsNotNull (ex
.Message
, "#B5");
642 Assert
.IsTrue (ex
.Message
.IndexOf ("'connect timeout'") != -1, "#B6:" + ex
.Message
);
643 Assert
.IsNull (ex
.ParamName
, "#B7");
645 // Input string was not in a correct format
646 FormatException fe
= (FormatException
) ex
.InnerException
;
647 Assert
.IsNull (fe
.InnerException
, "#B8");
648 Assert
.IsNotNull (fe
.Message
, "#B9");
653 cn
.ConnectionString
= "timeout=2147483648";
655 } catch (ArgumentException ex
) {
656 // Invalid value for key 'connect timeout'
657 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#C2");
658 Assert
.IsNotNull (ex
.InnerException
, "#C3");
659 Assert
.AreEqual (typeof (OverflowException
), ex
.InnerException
.GetType (), "#C4");
660 Assert
.IsNotNull (ex
.Message
, "#C5");
661 Assert
.IsTrue (ex
.Message
.IndexOf ("'connect timeout'") != -1, "#C6:" + ex
.Message
);
662 Assert
.IsNull (ex
.ParamName
, "#C7");
664 // Value was either too large or too small for an Int32
665 OverflowException oe
= (OverflowException
) ex
.InnerException
;
666 Assert
.IsNull (oe
.InnerException
, "#C8");
667 Assert
.IsNotNull (oe
.Message
, "#C9");
672 #if FEATURE_NO_BSD_SOCKETS
673 [ExpectedException (typeof (PlatformNotSupportedException
))]
675 public void ConnectionString_Database_Synonyms ()
677 SqlConnection cn
= null;
679 cn
= new SqlConnection ();
680 cn
.ConnectionString
= "Initial Catalog=db";
681 Assert
.AreEqual ("db", cn
.Database
);
683 cn
= new SqlConnection ();
684 cn
.ConnectionString
= "Database=db";
685 Assert
.AreEqual ("db", cn
.Database
);
689 #if FEATURE_NO_BSD_SOCKETS
690 [ExpectedException (typeof (PlatformNotSupportedException
))]
692 public void ConnectionString_DataSource_Synonyms ()
694 SqlConnection cn
= null;
696 cn
= new SqlConnection ();
697 cn
.ConnectionString
= "Data Source=server";
698 Assert
.AreEqual ("server", cn
.DataSource
);
700 cn
= new SqlConnection ();
701 cn
.ConnectionString
= "addr=server";
702 Assert
.AreEqual ("server", cn
.DataSource
);
704 cn
= new SqlConnection ();
705 cn
.ConnectionString
= "address=server";
706 Assert
.AreEqual ("server", cn
.DataSource
);
708 cn
= new SqlConnection ();
709 cn
.ConnectionString
= "network address=server";
710 Assert
.AreEqual ("server", cn
.DataSource
);
712 cn
= new SqlConnection ();
713 cn
.ConnectionString
= "server=server";
714 Assert
.AreEqual ("server", cn
.DataSource
);
718 #if FEATURE_NO_BSD_SOCKETS
719 [ExpectedException (typeof (PlatformNotSupportedException
))]
721 public void ConnectionString_MaxPoolSize ()
723 SqlConnection cn
= new SqlConnection ();
724 cn
.ConnectionString
= "Max Pool Size=2147483647";
725 cn
.ConnectionString
= "Max Pool Size=1";
726 cn
.ConnectionString
= "Max Pool Size=500";
730 #if FEATURE_NO_BSD_SOCKETS
731 [ExpectedException (typeof (PlatformNotSupportedException
))]
733 public void ConnectionString_MaxPoolSize_Invalid ()
735 SqlConnection cn
= new SqlConnection ();
739 cn
.ConnectionString
= "Max Pool Size=-1";
741 } catch (ArgumentException ex
) {
742 // Invalid value for key 'max pool size'
743 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#A2");
744 Assert
.IsNull (ex
.InnerException
, "#A3");
745 Assert
.IsNotNull (ex
.Message
, "#A4");
746 Assert
.IsTrue (ex
.Message
.IndexOf ("'max pool size'") != -1, "#A5:" + ex
.Message
);
747 Assert
.IsNull (ex
.ParamName
, "#A6");
752 cn
.ConnectionString
= "max Pool size=BB";
754 } catch (ArgumentException ex
) {
755 // Invalid value for key 'max pool size'
756 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#B2");
757 Assert
.IsNotNull (ex
.InnerException
, "#B3");
758 Assert
.AreEqual (typeof (FormatException
), ex
.InnerException
.GetType (), "#B4");
759 Assert
.IsNotNull (ex
.Message
, "#B5");
760 Assert
.IsTrue (ex
.Message
.IndexOf ("'max pool size'") != -1, "#B6:" + ex
.Message
);
761 Assert
.IsNull (ex
.ParamName
, "#B7");
763 // Input string was not in a correct format
764 FormatException fe
= (FormatException
) ex
.InnerException
;
765 Assert
.IsNull (fe
.InnerException
, "#B8");
766 Assert
.IsNotNull (fe
.Message
, "#B9");
771 cn
.ConnectionString
= "max pool size=2147483648";
773 } catch (ArgumentException ex
) {
774 // Invalid value for key 'max pool size'
775 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#C2");
776 Assert
.IsNotNull (ex
.InnerException
, "#C3");
777 Assert
.AreEqual (typeof (OverflowException
), ex
.InnerException
.GetType (), "#C4");
778 Assert
.IsNotNull (ex
.Message
, "#C5");
779 Assert
.IsTrue (ex
.Message
.IndexOf ("'max pool size'") != -1, "#C6:" + ex
.Message
);
780 Assert
.IsNull (ex
.ParamName
, "#C7");
782 // Value was either too large or too small for an Int32
783 OverflowException oe
= (OverflowException
) ex
.InnerException
;
784 Assert
.IsNull (oe
.InnerException
, "#C8");
785 Assert
.IsNotNull (oe
.Message
, "#C9");
788 // less than minimum (1)
790 cn
.ConnectionString
= "Min Pool Size=0;Max Pool Size=0";
792 } catch (ArgumentException ex
) {
793 // Invalid value for key 'max pool size'
794 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#D2");
795 Assert
.IsNull (ex
.InnerException
, "#D3");
796 Assert
.IsNotNull (ex
.Message
, "#D4");
797 Assert
.IsTrue (ex
.Message
.IndexOf ("'max pool size'") != -1, "#D5:" + ex
.Message
);
798 Assert
.IsNull (ex
.ParamName
, "#D6");
801 // less than min pool size
803 cn
.ConnectionString
= "Min Pool Size=5;Max Pool Size=4";
805 } catch (ArgumentException ex
) {
806 // Invalid min or max pool size values, min
807 // pool size cannot be greater than the max
809 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#E2");
810 Assert
.IsNull (ex
.InnerException
, "#E3");
811 Assert
.IsNotNull (ex
.Message
, "#E4");
812 Assert
.IsNull (ex
.ParamName
, "#E5");
817 #if FEATURE_NO_BSD_SOCKETS
818 [ExpectedException (typeof (PlatformNotSupportedException
))]
820 public void ConnectionString_MinPoolSize ()
822 SqlConnection cn
= new SqlConnection ();
823 cn
.ConnectionString
= "min Pool size=0";
824 cn
.ConnectionString
= "Min Pool size=100";
825 cn
.ConnectionString
= "Min Pool Size=2147483647;Max Pool Size=2147483647";
829 #if FEATURE_NO_BSD_SOCKETS
830 [ExpectedException (typeof (PlatformNotSupportedException
))]
832 public void ConnectionString_MinPoolSize_Invalid ()
834 SqlConnection cn
= new SqlConnection ();
838 cn
.ConnectionString
= "Min Pool Size=-1";
840 } catch (ArgumentException ex
) {
841 // Invalid value for key 'min pool size'
842 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#A2");
843 Assert
.IsNull (ex
.InnerException
, "#A3");
844 Assert
.IsNotNull (ex
.Message
, "#A4");
845 Assert
.IsTrue (ex
.Message
.IndexOf ("'min pool size'") != -1, "#A5:" + ex
.Message
);
846 Assert
.IsNull (ex
.ParamName
, "#A6");
851 cn
.ConnectionString
= "min Pool size=BB";
853 } catch (ArgumentException ex
) {
854 // Invalid value for key 'min pool size'
855 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#B2");
856 Assert
.IsNotNull (ex
.InnerException
, "#B3");
857 Assert
.AreEqual (typeof (FormatException
), ex
.InnerException
.GetType (), "#B4");
858 Assert
.IsNotNull (ex
.Message
, "#B5");
859 Assert
.IsTrue (ex
.Message
.IndexOf ("'min pool size'") != -1, "#B6:" + ex
.Message
);
860 Assert
.IsNull (ex
.ParamName
, "#B7");
862 // Input string was not in a correct format
863 FormatException fe
= (FormatException
) ex
.InnerException
;
864 Assert
.IsNull (fe
.InnerException
, "#B8");
865 Assert
.IsNotNull (fe
.Message
, "#B9");
870 cn
.ConnectionString
= "min pool size=2147483648";
872 } catch (ArgumentException ex
) {
873 // Invalid value for key 'min pool size'
874 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#C2");
875 Assert
.IsNotNull (ex
.InnerException
, "#C3");
876 Assert
.AreEqual (typeof (OverflowException
), ex
.InnerException
.GetType (), "#C4");
877 Assert
.IsNotNull (ex
.Message
, "#C5");
878 Assert
.IsTrue (ex
.Message
.IndexOf ("'min pool size'") != -1, "#C6:" + ex
.Message
);
879 Assert
.IsNull (ex
.ParamName
, "#C7");
881 // Value was either too large or too small for an Int32
882 OverflowException oe
= (OverflowException
) ex
.InnerException
;
883 Assert
.IsNull (oe
.InnerException
, "#C8");
884 Assert
.IsNotNull (oe
.Message
, "#C9");
889 #if FEATURE_NO_BSD_SOCKETS
890 [ExpectedException (typeof (PlatformNotSupportedException
))]
892 public void ConnectionString_MultipleActiveResultSets ()
894 SqlConnection cn
= new SqlConnection ();
895 cn
.ConnectionString
= "MultipleActiveResultSets=true";
899 #if FEATURE_NO_BSD_SOCKETS
900 [ExpectedException (typeof (PlatformNotSupportedException
))]
902 public void ConnectionString_MultipleActiveResultSets_Invalid ()
904 SqlConnection cn
= new SqlConnection ();
906 cn
.ConnectionString
= "MultipleActiveResultSets=1";
908 } catch (ArgumentException ex
) {
909 // Invalid value for key 'multipleactiveresultsets'
910 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#2");
911 Assert
.IsNull (ex
.InnerException
, "#3");
912 Assert
.IsNotNull (ex
.Message
, "#4");
913 Assert
.IsTrue (ex
.Message
.IndexOf ("'multipleactiveresultsets'") != -1, "#5:" + ex
.Message
);
914 Assert
.IsNull (ex
.ParamName
, "#6");
919 [Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
920 #if FEATURE_NO_BSD_SOCKETS
921 [ExpectedException (typeof (PlatformNotSupportedException
))]
923 public void ConnectionString_NetworkLibrary_Synonyms ()
925 SqlConnection cn
= new SqlConnection ();
926 cn
.ConnectionString
= "Net=DBMSSOCN";
927 cn
.ConnectionString
= "Network=DBMSSOCN";
928 cn
.ConnectionString
= "Network library=DBMSSOCN";
932 [Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22879
933 #if FEATURE_NO_BSD_SOCKETS
934 [ExpectedException (typeof (PlatformNotSupportedException
))]
936 public void ConnectionString_PacketSize ()
938 SqlConnection cn
= new SqlConnection ();
939 cn
.ConnectionString
= "Packet Size=1024";
940 Assert
.AreEqual (1024, cn
.PacketSize
, "#1");
941 cn
.ConnectionString
= "packet SizE=533";
942 Assert
.AreEqual (533, cn
.PacketSize
, "#2");
943 cn
.ConnectionString
= "packet SizE=512";
944 Assert
.AreEqual (512, cn
.PacketSize
, "#3");
945 cn
.ConnectionString
= "packet SizE=32768";
946 Assert
.AreEqual (32768, cn
.PacketSize
, "#4");
947 cn
.ConnectionString
= "packet Size=";
948 Assert
.AreEqual (8000, cn
.PacketSize
, "#5");
952 #if FEATURE_NO_BSD_SOCKETS
953 [ExpectedException (typeof (PlatformNotSupportedException
))]
955 public void ConnectionString_PacketSize_Invalid ()
957 SqlConnection cn
= new SqlConnection ();
959 // invalid packet size (< minimum)
961 cn
.ConnectionString
= "Packet Size=511";
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 (), "#A2");
967 Assert
.IsNull (ex
.InnerException
, "#A3");
968 Assert
.IsNotNull (ex
.Message
, "#A4");
969 Assert
.IsTrue (ex
.Message
.IndexOf ("'Packet Size'") != -1, "#A5:" + ex
.Message
);
970 Assert
.IsNull (ex
.ParamName
, "#A6");
973 // invalid packet size (> maximum)
975 cn
.ConnectionString
= "packet SIze=32769";
977 } catch (ArgumentException ex
) {
978 // Invalid 'Packet Size'. The value must be an
979 // integer >= 512 and <= 32768
980 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#B2");
981 Assert
.IsNull (ex
.InnerException
, "#B3");
982 Assert
.IsNotNull (ex
.Message
, "#B4");
983 Assert
.IsTrue (ex
.Message
.IndexOf ("'Packet Size'") != -1, "#B5:" + ex
.Message
);
984 Assert
.IsNull (ex
.ParamName
, "#B6");
989 cn
.ConnectionString
= "packet SIze=2147483648";
991 } catch (ArgumentException ex
) {
992 // Invalid value for key 'packet size'
993 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#C2");
994 Assert
.IsNotNull (ex
.InnerException
, "#C3");
995 Assert
.AreEqual (typeof (OverflowException
), ex
.InnerException
.GetType (), "#C4");
996 Assert
.IsNotNull (ex
.Message
, "#C5");
997 Assert
.IsTrue (ex
.Message
.IndexOf ("'packet size'") != -1, "#C6:" + ex
.Message
);
998 Assert
.IsNull (ex
.ParamName
, "#C7");
1000 // Value was either too large or too small for an Int32
1001 OverflowException oe
= (OverflowException
) ex
.InnerException
;
1002 Assert
.IsNull (oe
.InnerException
, "#C8");
1003 Assert
.IsNotNull (oe
.Message
, "#C9");
1008 #if FEATURE_NO_BSD_SOCKETS
1009 [ExpectedException (typeof (PlatformNotSupportedException
))]
1011 public void ConnectionString_Password_Synonyms ()
1013 SqlConnection cn
= new SqlConnection ();
1014 cn
.ConnectionString
= "Password=scrambled";
1015 cn
.ConnectionString
= "Pwd=scrambled";
1019 #if FEATURE_NO_BSD_SOCKETS
1020 [ExpectedException (typeof (PlatformNotSupportedException
))]
1022 public void ConnectionString_PersistSecurityInfo_Synonyms ()
1024 SqlConnection cn
= new SqlConnection ();
1025 cn
.ConnectionString
= "Persist Security Info=true";
1026 cn
.ConnectionString
= "PersistSecurityInfo=true";
1030 #if FEATURE_NO_BSD_SOCKETS
1031 [ExpectedException (typeof (PlatformNotSupportedException
))]
1033 public void ConnectionString_UserID_Synonyms ()
1035 SqlConnection cn
= new SqlConnection ();
1036 cn
.ConnectionString
= "User Id=test";
1037 cn
.ConnectionString
= "User=test";
1038 cn
.ConnectionString
= "Uid=test";
1042 #if FEATURE_NO_BSD_SOCKETS
1043 [ExpectedException (typeof (PlatformNotSupportedException
))]
1045 public void ConnectionString_UserInstance ()
1047 SqlConnection cn
= new SqlConnection ();
1048 cn
.ConnectionString
= "User Instance=true";
1052 #if FEATURE_NO_BSD_SOCKETS
1053 [ExpectedException (typeof (PlatformNotSupportedException
))]
1055 public void ConnectionString_UserInstance_Invalid ()
1057 SqlConnection cn
= new SqlConnection ();
1059 cn
.ConnectionString
= "User Instance=1";
1061 } catch (ArgumentException ex
) {
1062 // Invalid value for key 'user instance'
1063 Assert
.AreEqual (typeof (ArgumentException
), ex
.GetType (), "#2");
1064 Assert
.IsNull (ex
.InnerException
, "#3");
1065 Assert
.IsNotNull (ex
.Message
, "#4");
1066 Assert
.IsTrue (ex
.Message
.IndexOf ("'user instance'") != -1, "#5:" + ex
.Message
);
1067 Assert
.IsNull (ex
.ParamName
, "#6");
1072 [Category("NotWorking")] // https://github.com/dotnet/corefx/issues/22474
1073 #if FEATURE_NO_BSD_SOCKETS
1074 [ExpectedException (typeof (PlatformNotSupportedException
))]
1076 public void ConnectionString_OtherKeywords ()
1078 SqlConnection cn
= new SqlConnection ();
1079 cn
.ConnectionString
= "Application Name=test";
1080 cn
.ConnectionString
= "App=test";
1081 cn
.ConnectionString
= "Connection Reset=true";
1082 cn
.ConnectionString
= "Current Language=test";
1083 cn
.ConnectionString
= "Language=test";
1084 cn
.ConnectionString
= "Encrypt=false";
1085 //cn.ConnectionString = "Encrypt=true";
1086 //cn.ConnectionString = "Enlist=false";
1087 cn
.ConnectionString
= "Enlist=true";
1088 cn
.ConnectionString
= "Integrated Security=true";
1089 cn
.ConnectionString
= "Trusted_connection=true";
1090 cn
.ConnectionString
= "Max Pool Size=10";
1091 cn
.ConnectionString
= "Min Pool Size=10";
1092 cn
.ConnectionString
= "Pooling=true";
1093 cn
.ConnectionString
= "attachdbfilename=dunno";
1094 cn
.ConnectionString
= "extended properties=dunno";
1095 cn
.ConnectionString
= "initial file name=dunno";
1099 #if FEATURE_NO_BSD_SOCKETS
1100 [ExpectedException (typeof (PlatformNotSupportedException
))]
1102 public void Open_ConnectionString_Empty ()
1104 SqlConnection cn
= new SqlConnection ();
1105 cn
.ConnectionString
= string.Empty
;
1110 } catch (InvalidOperationException ex
) {
1111 // The ConnectionString property has not been
1113 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
1114 Assert
.IsNull (ex
.InnerException
, "#3");
1115 Assert
.IsNotNull (ex
.Message
, "#4");
1120 #if FEATURE_NO_BSD_SOCKETS
1121 [ExpectedException (typeof (PlatformNotSupportedException
))]
1123 public void Open_ConnectionString_Null ()
1125 SqlConnection cn
= new SqlConnection ();
1126 cn
.ConnectionString
= null;
1131 } catch (InvalidOperationException ex
) {
1132 // The ConnectionString property has not been
1134 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
1135 Assert
.IsNull (ex
.InnerException
, "#3");
1136 Assert
.IsNotNull (ex
.Message
, "#4");
1141 #if FEATURE_NO_BSD_SOCKETS
1142 [ExpectedException (typeof (PlatformNotSupportedException
))]
1144 public void Open_ConnectionString_Whitespace ()
1146 SqlConnection cn
= new SqlConnection ();
1147 cn
.ConnectionString
= " ";
1152 } catch (InvalidOperationException ex
) {
1153 // The ConnectionString property has not been
1155 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#2");
1156 Assert
.IsNull (ex
.InnerException
, "#3");
1157 Assert
.IsNotNull (ex
.Message
, "#4");
1162 #if FEATURE_NO_BSD_SOCKETS
1163 [ExpectedException (typeof (PlatformNotSupportedException
))]
1165 public void ServerVersion_Connection_Closed ()
1167 SqlConnection cn
= new SqlConnection ();
1169 Assert
.Fail ("#A1:" + cn
.ServerVersion
);
1170 } catch (InvalidOperationException ex
) {
1171 // Invalid operation. The connection is closed
1172 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#A2");
1173 Assert
.IsNull (ex
.InnerException
, "#A3");
1174 Assert
.IsNotNull (ex
.Message
, "#A4");
1177 cn
= new SqlConnection ("server=SQLSRV; database=Mono;");
1179 Assert
.Fail ("#B1:" + cn
.ServerVersion
);
1180 } catch (InvalidOperationException ex
) {
1181 // Invalid operation. The connection is closed
1182 Assert
.AreEqual (typeof (InvalidOperationException
), ex
.GetType (), "#B2");
1183 Assert
.IsNull (ex
.InnerException
, "#B3");
1184 Assert
.IsNotNull (ex
.Message
, "#B4");