2 // SqlDataAdapterTest.cs - NUnit Test Cases for testing the
3 // SqlDataAdapter class
5 // Senganal T (tsenganal@novell.com)
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;
35 using System.Collections;
37 namespace MonoTests.System.Data
40 [Category ("sqlserver")]
41 public class SqlConnectionTest
43 SqlConnection conn = null ;
44 String connectionString = ConnectionManager.Singleton.ConnectionString;
46 ArrayList invalidConnectionStrings = null;
47 int stateChangeEventCount = 0;
48 int disposedEventCount = 0;
49 int infoMessageEventCount = 0;
51 void populateTestData ()
53 invalidConnectionStrings = new ArrayList ();
54 // shud be got from a config file ..
55 //list of invalid and valid conn strings;
56 invalidConnectionStrings.Add ("InvalidConnectionString");
57 invalidConnectionStrings.Add ("invalidKeyword=10");
58 invalidConnectionStrings.Add ("Packet Size=511");
59 invalidConnectionStrings.Add ("Packet Size=32768");
60 invalidConnectionStrings.Add ("Connect Timeout=-1");
61 invalidConnectionStrings.Add ("Max Pool Size=-1");
62 invalidConnectionStrings.Add ("Min Pool Size=-1");
71 public void TearDown ()
78 public void DefaultConstructorTest ()
80 SqlConnection conn = new SqlConnection ();
81 Assert.AreEqual ("", conn.ConnectionString,
82 "#1 Default Connection String should be empty");
83 Assert.AreEqual (15, conn.ConnectionTimeout,
84 "#2 Default ConnectionTimeout should be 15" );
85 Assert.AreEqual ("", conn.Database,
86 "#3 Default Database should be empty");
87 Assert.AreEqual ("", conn.DataSource,
88 "#4 Default DataSource should be empty");
89 Assert.AreEqual (8192, conn.PacketSize,"#5 Default Packet Size is 8192");
90 Assert.AreEqual (Dns.GetHostName().ToUpper (), conn.WorkstationId.ToUpper (),
91 "#6 Default Workstationid shud be hostname");
92 Assert.AreEqual (ConnectionState.Closed, conn.State,
93 "#7 Connection State shud be closed by default");
97 public void OverloadedConstructorTest ()
99 // Test Exceptions are thrown for Invalid Connection Strings
102 foreach (String invalidConnString in invalidConnectionStrings) {
105 conn = new SqlConnection ((string)invalidConnString);
106 Assert.Fail ("#1 Exception must be thrown");
107 }catch (AssertionException e) {
109 }catch (Exception e) {
110 Assert.AreEqual (typeof(ArgumentException), e.GetType(),
111 "Incorrect Exception" + e.StackTrace);
116 //do i need to check for all the synonyms..
117 conn = new SqlConnection (
118 "Timeout=10;Connect Timeout=20;Connection Timeout=30");
119 Assert.AreEqual (30, conn.ConnectionTimeout,
120 "## The last set value shud be taken");
121 conn = new SqlConnection (
122 "Connect Timeout=100;Connection Timeout=200;Timeout=300");
123 Assert.AreEqual (300, conn.ConnectionTimeout,
124 "## The last set value shud be taken");
125 conn = new SqlConnection (
126 "Connection Timeout=1000;Timeout=2000;Connect Timeout=3000");
127 Assert.AreEqual (3000, conn.ConnectionTimeout,
128 "## The last set value shud be taken");
130 // Test if properties are set correctly
132 //'==' doesent work correctly in both msdotnet and mono
134 conn = new SqlConnection ("server=local==host;database=tmp;");
135 Assert.AreEqual ("local==host", conn.DataSource,
136 "# Datasource name is set incorrectly");
138 string connStr = "Server='loca\"lhost';Database='''Db'; packet Size=\"512\";";
139 connStr += "connect Timeout=20;Workstation Id=\"'\"\"desktop\";";
140 conn = new SqlConnection (connStr);
141 Assert.AreEqual (connStr , conn.ConnectionString , "#1");
142 Assert.AreEqual ("loca\"lhost" , conn.DataSource , "#2");
143 Assert.AreEqual ("'Db" , conn.Database , "#3");
144 Assert.AreEqual (512 , conn.PacketSize , "#4");
145 Assert.AreEqual (20 , conn.ConnectionTimeout , "#5");
146 Assert.AreEqual ("'\"desktop" , conn.WorkstationId , "#6");
147 Assert.AreEqual (ConnectionState.Closed , conn.State , "#7");
151 public void OpenTest ()
153 conn = new SqlConnection (connectionString);
154 ArrayList validIncorrectConnStrings = new ArrayList();
155 string validConnString = connectionString;
157 validIncorrectConnStrings.Add (
158 validConnString+"user id=invalidLogin");
159 validIncorrectConnStrings.Add (
160 validConnString+"database=invalidDB");
161 validIncorrectConnStrings.Add (
162 validConnString+";password=invalidPassword");
163 validIncorrectConnStrings.Add (
164 validConnString+";server=invalidServerName");
167 foreach (string connString in validIncorrectConnStrings) {
170 conn.ConnectionString = connString;
172 Assert.Fail (String.Format (
173 "#1_{0} Incorrect Connection String",count));
175 }catch (AssertionException e) {
177 }catch (Exception e) {
178 Assert.AreEqual (typeof (SqlException), e.GetType (),
179 "#2 Incorrect Exception" + e.StackTrace);
183 // Test connection is Opened for a valid Connection String
184 conn.ConnectionString = connectionString;
186 Assert.AreEqual (ConnectionState.Open, conn.State,
187 "#3 Connection State Should be OPEN");
189 // Test Exception is thrown on opening an OPEN Connection
192 Assert.AreEqual (typeof (InvalidOperationException), null,
193 "#1 Connection is Already Open");
194 }catch (AssertionException e) {
196 }catch (Exception e) {
197 Assert.AreEqual (typeof(InvalidOperationException), e.GetType (),
198 "#2 Incorect Exception.");
203 // Test if localhost is assumed when servername is empty/missing
204 // NOTE : msdotnet contradicts doc
206 Assumes the server is localhost .. need to test this with mono on windows
207 conn.ConnectionString = connectionString + "server=;";
210 }catch (Exception e) {
211 Assert.Fail ("## If server name is not given or empty ,localhost shud be tried");
219 public void OpenTest_1 ()
221 SqlConnection conn = new SqlConnection ();
223 conn.ConnectionString = "";
226 Assert.Fail ("#1 Should throw ArgumentException and not SqlException");
227 } catch (InvalidOperationException) {
230 conn.ConnectionString = " ";
233 Assert.Fail ("#2 Should throw ArgumentException and not SqlException");
234 } catch (InvalidOperationException) {
239 public void CreateCommandTest ()
241 conn = new SqlConnection (connectionString);
242 IDbCommand cmd = conn.CreateCommand ();
243 Assert.AreSame (conn, cmd.Connection,
244 "#1 Connection instance should be the same");
248 public void CloseTest ()
250 conn = new SqlConnection (connectionString);
252 Assert.AreEqual (ConnectionState.Open, conn.State,
253 "#1 Connection State should be : Open");
255 Assert.AreEqual (ConnectionState.Closed, conn.State,
256 "#1 Connection State Should : Closed");
257 // Test Closing an already closed connection is Valid..
262 public void DisposeTest ()
264 SqlConnection conn = new SqlConnection (connectionString);
266 Assert.AreEqual ("", conn.ConnectionString,
267 "#1 Dispose shud make the Connection String empty");
268 Assert.AreEqual (15, conn.ConnectionTimeout,
269 "#2 Default ConnectionTimeout : 15" );
270 Assert.AreEqual ("", conn.Database,
271 "#3 Default Database : empty");
272 Assert.AreEqual ("", conn.DataSource,
273 "#4 Default DataSource : empty");
274 Assert.AreEqual (8192, conn.PacketSize,
275 "#5 Default Packet Size : 8192");
276 Assert.AreEqual (Dns.GetHostName().ToUpper (), conn.WorkstationId.ToUpper (),
277 "#6 Default Workstationid : hostname");
278 Assert.AreEqual (ConnectionState.Closed, conn.State,
279 "#7 Default State : CLOSED ");
281 conn = new SqlConnection ();
282 //shud not throw exception
287 public void ChangeDatabaseTest ()
289 conn = new SqlConnection (connectionString);
290 String database = conn.Database;
292 //Test if exception is thrown if connection is closed
294 conn.ChangeDatabase ("database");
295 Assert.AreEqual (typeof (InvalidOperationException), null,
296 "#1 Connection is Closed");
297 }catch (AssertionException e){
299 }catch (Exception e) {
300 Assert.AreEqual (typeof (InvalidOperationException), e.GetType(),
301 "#2 Incorrect Exception : " + e.StackTrace);
304 //Test if exception is thrown for invalid Database Names
305 //need to add more to the list
307 String[] InvalidDatabaseNames = {"", null, " "};
308 for (int i = 0; i < InvalidDatabaseNames.Length ; ++i) {
310 conn.ChangeDatabase (InvalidDatabaseNames[i]);
311 Assert.AreEqual (typeof (ArgumentException), null,
312 string.Format ("#3_{0} Exception not thrown",i));
313 }catch (AssertionException e) {
315 }catch (Exception e) {
316 Assert.AreEqual (typeof(ArgumentException), e.GetType (),
317 string.Format( "#4_{0} Incorrect Exception : {1}",
320 Assert.AreEqual (database, conn.Database,
321 "#4 The Database shouldnt get changed if Operation Failed");
324 //Test if exception is thrown if database name is non-existent
326 conn.ChangeDatabase ("invalidDB");
327 Assert.Fail ("#5 Exception must be thrown if database doesent exist");
328 }catch (AssertionException e) {
330 }catch (Exception e) {
331 Assert.AreEqual (typeof(SqlException), e.GetType (),
332 "#6 Incorrect Exception" + e.StackTrace);
336 //Test if '-' is a valid character in a database name
337 //TODO : Check for database names that have more special Characters..
338 conn.ConnectionString = connectionString;
341 conn.ChangeDatabase ("mono-test");
342 Assert.AreEqual ("mono-test", conn.Database,
343 "#7 Database name should be mono-test");
344 }catch (AssertionException e) {
346 }catch (Exception e){
347 Assert.Fail ("#8 Unexpected Exception : DB Name can have a '-' : "
353 public void BeginTransactionTest()
355 conn = new SqlConnection (connectionString);
356 SqlTransaction trans = null ;
359 trans = conn.BeginTransaction ();
360 Assert.Fail ("#1 Connection must be Open to Begin a Transaction");
361 }catch (AssertionException e) {
363 }catch (Exception e) {
364 Assert.AreEqual (typeof (InvalidOperationException), e.GetType(),
365 "#2 Incorrect Exception" + e.StackTrace);
369 trans = conn.BeginTransaction ();
370 Assert.AreSame (conn, trans.Connection,
371 "#3 Transaction should reference the same connection");
372 Assert.AreEqual (IsolationLevel.ReadCommitted, trans.IsolationLevel,
373 "#4 Isolation Level shud be ReadCommitted");
377 trans = conn.BeginTransaction ();
378 trans = conn.BeginTransaction ();
379 conn.BeginTransaction ();
380 Assert.Fail ("#5 Parallel Transactions are not supported");
381 }catch (AssertionException e) {
383 }catch (Exception e) {
384 Assert.AreEqual (typeof(InvalidOperationException), e.GetType(),
385 "#6 Incorrect Exception" + e.StackTrace);
391 trans = conn.BeginTransaction ();
393 trans = conn.BeginTransaction ();
395 trans = conn.BeginTransaction ();
396 }catch (Exception e) {
397 Assert.Fail ("#7 Transaction can be opened after a rollback/commit");
404 public void ConnectionStringPropertyTest ()
406 conn = new SqlConnection (connectionString) ;
407 // Test Repeated Keyoword ..Should take the latest value
408 conn.ConnectionString = conn.ConnectionString + ";server=RepeatedServer;" ;
409 Assert.AreEqual ("RepeatedServer", ((SqlConnection)conn).DataSource,
410 "#1 if keyword is repeated, the latest value should be taken");
411 conn.ConnectionString += ";database=gen;Initial Catalog=gen1";
412 Assert.AreEqual ("gen1", conn.Database,
413 "#2 database and initial catalog are synonyms .. ");
415 // Test if properties are set correctly
416 string str = "server=localhost1;database=db;user id=user;";
417 str += "password=pwd;Workstation ID=workstation;Packet Size=512;";
418 str += "Connect Timeout=10";
419 conn.ConnectionString = str;
421 Assert.AreEqual ("localhost1", conn.DataSource,
422 "#3 DataSource name should be same as passed");
423 Assert.AreEqual ("db", conn.Database,
424 "#4 Database name shud be same as passed");
425 Assert.AreEqual (ConnectionState.Closed, conn.State,
426 "#5 Connection shud be in closed state");
427 Assert.AreEqual ("workstation", conn.WorkstationId,
428 "#6 Workstation Id shud be same as passed");
429 Assert.AreEqual (512, conn.PacketSize,
430 "#7 Packetsize shud be same as passed");
431 Assert.AreEqual (10, conn.ConnectionTimeout,
432 "#8 ConnectionTimeout shud be same as passed");
434 // Test if any leftover values exist from previous invocation.
435 conn.ConnectionString = connectionString;
436 conn.ConnectionString = "";
437 Assert.AreEqual ("", conn.DataSource,
438 "#9 Datasource shud be reset to Default : Empty");
439 Assert.AreEqual ("", conn.Database,
440 "#10 Database shud reset to Default : Empty");
441 Assert.AreEqual (8192, conn.PacketSize,
442 "#11 Packetsize shud be reset to Default : 8192");
443 Assert.AreEqual (15, conn.ConnectionTimeout,
444 "#12 ConnectionTimeour shud be reset to Default : 15");
445 Assert.AreEqual (Dns.GetHostName ().ToUpper (), conn.WorkstationId.ToUpper (),
446 "#13 WorkstationId shud be reset to Default : Hostname");
448 // Test Argument Exception is thrown for Invalid Connection Strings
449 foreach (string connString in invalidConnectionStrings) {
451 conn.ConnectionString = connString;
453 "#14 Exception should be thrown");
454 }catch (AssertionException e){
456 }catch (Exception e) {
457 Assert.AreEqual (typeof (ArgumentException), e.GetType(),
458 "#15 Incorrect Exception" + e.StackTrace);
462 // Test if ConnectionString is read-only when Connection is OPEN
463 conn.ConnectionString = connectionString;
466 Assert.AreEqual (conn.State, ConnectionState.Open,
467 "#16 Connection shud be open");
468 conn.ConnectionString = "server=localhost;database=tmp;" ;
470 "#17 ConnectionString should Read-Only when Connection is Open");
471 }catch (AssertionException e){
473 }catch (Exception e) {
474 Assert.AreEqual (typeof(InvalidOperationException), e.GetType(),
475 "#18 Incorrect Exception" + e.StackTrace);
481 public void ServerVersionTest ()
483 conn = new SqlConnection (connectionString);
485 // Test InvalidOperation Exception is thrown if Connection is CLOSED
487 string s = conn.ServerVersion;
489 "#1 InvalidOperation Exception Must be thrown if conn is closed");
490 }catch (AssertionException e){
492 }catch (Exception e){
493 Assert.AreEqual(typeof (InvalidOperationException), e.GetType (),
494 "#2 Incorrect Exception" + e.StackTrace);
497 // Test if Release Version is as per specification.
499 String[] version = conn.ServerVersion.Split ('.') ;
500 Assert.AreEqual (2, version[0].Length,
501 "#2 The Major release shud be exactly 2 characters");
502 Assert.AreEqual (2, version[1].Length,
503 "#3 The Minor release shud be exactly 2 characters");
504 Assert.AreEqual (4, version[2].Length,
505 "#4 The Release version should be exactly 4 digits");
509 public void DatabasePropertyTest ()
511 conn = new SqlConnection (connectionString);
512 string database = conn.Database ;
514 // Test if database property is updated when a query changes database
516 SqlCommand cmd = new SqlCommand ("use [mono-test]" , conn);
517 cmd.ExecuteNonQuery ();
518 Assert.AreEqual ("mono-test", conn.Database,
519 "#1 DATABASE name shud change if query changes the db");
521 Assert.AreEqual (database, conn.Database,
522 "#2 Shud be back to default value");
524 // Test if the database property is reset on re-opening the connection
525 conn.ConnectionString = connectionString;
527 Assert.AreEqual (database, conn.Database,
528 "#3 Shud be back to original value");
533 public void StateChangeEventTest ()
535 conn = new SqlConnection (connectionString);
536 conn.StateChange += new StateChangeEventHandler (
537 StateChangeHandlerTest1);
541 Assert.AreEqual (2, stateChangeEventCount,
542 "#1 The handler shud be called twice");
543 stateChangeEventCount =0 ;
544 conn.StateChange -= new StateChangeEventHandler (
545 StateChangeHandlerTest1);
546 // NOTE : Need to check the behavior if an exception is raised
551 public void DisposedEventTest ()
553 conn = new SqlConnection (connectionString);
554 conn.Disposed += new EventHandler (DisposedEventHandlerTest1);
556 Assert.AreEqual (1, disposedEventCount,
557 "#1 Disposed eventhandler shud be called");
560 void StateChangeHandlerTest1 (object sender , StateChangeEventArgs e)
562 Assert.IsTrue ((e.CurrentState != e.OriginalState),
563 "#1 Current and Original state shud be different");
564 Assert.AreEqual (e.CurrentState, conn.State,
565 "The conn state and the arg received in event shud be same");
566 stateChangeEventCount++ ;
569 void DisposedEventHandlerTest1 (object sender , EventArgs e)
571 disposedEventCount++;
576 [Category ("sqlserver")]
577 public class GetSchemaTest
579 SqlConnection conn = null;
580 String connectionString = ConnectionManager.Singleton.ConnectionString;
585 conn = new SqlConnection(connectionString);
589 public void TearDown()
594 public void GetSchemaTest1()
597 DataTable tab1 = conn.GetSchema("databases");
598 foreach (DataRow row in tab1.Rows)
600 foreach (DataColumn col in tab1.Columns)
602 if (col.ColumnName.ToString() == "database_name" && row[col].ToString() == "monotest")
611 Assert.AreEqual(true, flag, "#GS1 failed");
614 [ExpectedException(typeof(ArgumentException))]
615 public void GetSchemaTest2()
617 conn.GetSchema(null);
620 public void GetSchemaTest3()
623 DataTable tab1 = conn.GetSchema("ForeignKeys");
624 foreach (DataRow row in tab1.Rows)
626 foreach (DataColumn col in tab1.Columns)
629 * We need to consider multiple values
631 if (col.ColumnName.ToString() == "TABLE_NAME" && row[col].ToString() == "tmptable1")
640 Assert.AreEqual(true, flag, "#GS3 failed");
643 public void GetSchemaTest4()
646 DataTable tab1 = conn.GetSchema("Indexes");
647 foreach (DataRow row in tab1.Rows)
649 foreach (DataColumn col in tab1.Columns)
652 * We need to consider multiple values
654 if (col.ColumnName.ToString() == "table_name" && row[col].ToString() == "binary_family")
663 Assert.AreEqual(true, flag, "#GS4 failed");
666 public void GetSchemaTest5()
669 DataTable tab1 = conn.GetSchema("IndexColumns");
670 foreach (DataRow row in tab1.Rows)
672 foreach (DataColumn col in tab1.Columns)
675 * We need to consider multiple values
677 if (col.ColumnName.ToString() == "table_name" && row[col].ToString() == "binary_family")
686 Assert.AreEqual(true, flag, "#GS5 failed");
689 public void GetSchemaTest6()
692 DataTable tab1 = conn.GetSchema("Procedures");
693 foreach (DataRow row in tab1.Rows)
695 foreach (DataColumn col in tab1.Columns)
698 * We need to consider multiple values
700 if (col.ColumnName.ToString() == "SPECIFIC_NAME" && row[col].ToString() == "sp_get_age")
709 Assert.AreEqual(true, flag, "#GS6 failed");
712 public void GetSchemaTest7()
715 DataTable tab1 = conn.GetSchema("ProcedureParameters");
716 foreach (DataRow row in tab1.Rows)
718 foreach (DataColumn col in tab1.Columns)
721 * We need to consider multiple values
723 if (col.ColumnName.ToString() == "SPECIFIC_NAME" && row[col].ToString() == "sp_get_age")
732 Assert.AreEqual(true, flag, "#GS7 failed");
735 public void GetSchemaTest8()
738 DataTable tab1 = conn.GetSchema("Tables");
739 foreach (DataRow row in tab1.Rows)
741 foreach (DataColumn col in tab1.Columns)
744 * We need to consider multiple values
746 if (col.ColumnName.ToString() == "TABLE_NAME" && row[col].ToString() == "binary_family")
755 Assert.AreEqual(true, flag, "#GS8 failed");
758 public void GetSchemaTest9()
761 DataTable tab1 = conn.GetSchema("Columns");
762 foreach (DataRow row in tab1.Rows)
764 foreach (DataColumn col in tab1.Columns)
767 * We need to consider multiple values
769 if (col.ColumnName.ToString() == "TABLE_NAME" && row[col].ToString() == "binary_family")
778 Assert.AreEqual(true, flag, "#GS9 failed");
780 public void GetSchemaTest10()
783 DataTable tab1 = conn.GetSchema("Users");
784 foreach (DataRow row in tab1.Rows)
786 foreach (DataColumn col in tab1.Columns)
789 * We need to consider multiple values
791 if (col.ColumnName.ToString() == "user_name" && row[col].ToString() == "public")
800 Assert.AreEqual(true, flag, "#GS10 failed");
802 public void GetSchemaTest11()
805 DataTable tab1 = conn.GetSchema("Views");
806 flag = true; // FIXME: Currently MS-SQL 2005 returns empty table. Remove this flag ASAP.
807 foreach (DataRow row in tab1.Rows)
809 foreach (DataColumn col in tab1.Columns)
812 * We need to consider multiple values.
814 if (col.ColumnName.ToString() == "user_name" && row[col].ToString() == "public")
823 Assert.AreEqual(true, flag, "#GS11 failed");
825 public void GetSchemaTest12()
828 DataTable tab1 = conn.GetSchema("ViewColumns");
829 flag = true; // FIXME: Currently MS-SQL 2005 returns empty table. Remove this flag ASAP.
830 foreach (DataRow row in tab1.Rows)
832 foreach (DataColumn col in tab1.Columns)
835 * We need to consider multiple values.
837 if (col.ColumnName.ToString() == "user_name" && row[col].ToString() == "public")
846 Assert.AreEqual(true, flag, "#GS12 failed");
848 public void GetSchemaTest13()
851 DataTable tab1 = conn.GetSchema("UserDefineTypes");
852 flag = true; // FIXME: Currently MS-SQL 2005 returns empty table. Remove this flag ASAP.
853 foreach (DataRow row in tab1.Rows)
855 foreach (DataColumn col in tab1.Columns)
858 * We need to consider multiple values.
860 if (col.ColumnName.ToString() == "user_name" && row[col].ToString() == "public")
869 Assert.AreEqual(true, flag, "#GS13 failed");
872 public void GetSchemaTest14()
875 string [] restrictions = new string[4];
877 restrictions[0] = "monotest";
878 restrictions[1] = "dbo";
879 restrictions[2] = null;
880 restrictions[3] = "BASE TABLE";
881 DataTable tab1 = conn.GetSchema("Tables", restrictions);
882 foreach (DataRow row in tab1.Rows)
884 foreach (DataColumn col in tab1.Columns)
887 * We need to consider multiple values
889 if (col.ColumnName.ToString() == "TABLE_NAME" && row[col].ToString() == "binary_family")
898 Assert.AreEqual(true, flag, "#GS14 failed");
901 public void GetSchemaTest15()
904 string [] restrictions = new string[4];
906 restrictions[0] = "monotest";
907 restrictions[1] = null;
908 restrictions[2] = "binary_family";
909 restrictions[3] = null;
910 DataTable tab1 = conn.GetSchema("IndexColumns", restrictions);
911 foreach (DataRow row in tab1.Rows)
913 foreach (DataColumn col in tab1.Columns)
916 * We need to consider multiple values
918 if (col.ColumnName.ToString() == "table_name" && row[col].ToString() == "binary_family")
927 Assert.AreEqual(true, flag, "#GS15 failed");
930 public void GetSchemaTest16()
933 string [] restrictions = new string[4];
935 restrictions[0] = "monotest";
936 restrictions[1] = null;
937 restrictions[2] = "sp_get_age";
938 restrictions[3] = null;
939 DataTable tab1 = conn.GetSchema("Procedures", restrictions);
940 foreach (DataRow row in tab1.Rows)
942 foreach (DataColumn col in tab1.Columns)
945 * We need to consider multiple values
947 if (col.ColumnName.ToString() == "ROUTINE_NAME" && row[col].ToString() == "sp_get_age")
956 Assert.AreEqual(true, flag, "#GS16 failed");
959 public void GetSchemaTest17()
962 DataTable tab1 = conn.GetSchema();
963 foreach (DataRow row in tab1.Rows)
965 foreach (DataColumn col in tab1.Columns)
968 * We need to consider multiple values
970 if (col.ColumnName.ToString() == "CollectionName" && row[col].ToString() == "UserDefinedTypes")
979 Assert.AreEqual(true, flag, "#GS17 failed");
982 public void GetSchemaTest18()
985 DataTable tab1 = conn.GetSchema("RESTRICTIONS");
986 foreach (DataRow row in tab1.Rows)
988 foreach (DataColumn col in tab1.Columns)
991 * We need to consider multiple values
993 if (col.ColumnName.ToString() == "RestrictionDefault" && row[col].ToString() == "CONSTRAINT_NAME")
1002 Assert.AreEqual(true, flag, "#GS18 failed");
1005 [ExpectedException(typeof(ArgumentException))]
1006 public void GetSchemaTest19()
1008 String [] restrictions = new String[1];
1009 DataTable tab1 = conn.GetSchema("RESTRICTIONS", restrictions);
1012 public void GetSchemaTest20()
1015 DataTable tab1 = conn.GetSchema("DataTypes");
1016 foreach (DataRow row in tab1.Rows)
1018 foreach (DataColumn col in tab1.Columns)
1021 * We need to consider multiple values
1023 if (col.ColumnName.ToString() == "TypeName" && row[col].ToString() == "uniqueidentifier")
1032 Assert.AreEqual(true, flag, "#GS20 failed");
1035 public void GetSchemaTest21()
1038 DataTable tab1 = conn.GetSchema();
1039 foreach (DataRow row in tab1.Rows)
1041 foreach (DataColumn col in tab1.Columns)
1044 * We need to consider multiple values
1046 if (col.ColumnName.ToString() == "CollectionName" && row[col].ToString() == "UserDefinedTypes")
1055 Assert.AreEqual(true, flag, "#GS21 failed");
1058 public void GetSchemaTest22()
1061 DataTable tab1 = conn.GetSchema("ReservedWords");
1062 foreach (DataRow row in tab1.Rows)
1064 foreach (DataColumn col in tab1.Columns)
1067 * We need to consider multiple values
1069 if (col.ColumnName.ToString() == "ReservedWord" && row[col].ToString() == "UPPER")
1078 Assert.AreEqual(true, flag, "#GS22 failed");
1081 public void GetSchemaTest23()
1084 DataTable tab1 = conn.GetSchema("ReservedWords");
1085 foreach (DataRow row in tab1.Rows)
1087 foreach (DataColumn col in tab1.Columns)
1090 * We need to consider multiple values
1092 if (col.ColumnName.ToString() == "ReservedWord" && row[col].ToString() == "upper")
1101 Assert.AreEqual(false, flag, "#GS23 failed");
1104 public void GetSchemaTest24()
1107 string [] restrictions = new string[4];
1109 restrictions[0] = "monotest";
1110 restrictions[1] = null;
1111 restrictions[2] = "sp_get_age";
1112 restrictions[3] = null;
1113 DataTable tab1 = conn.GetSchema("Procedures", restrictions);
1114 foreach (DataRow row in tab1.Rows)
1116 foreach (DataColumn col in tab1.Columns)
1119 * We need to consider multiple values
1121 if (col.ColumnName.ToString() == "ROUTINE_NAME" && row[col].ToString() == "mono")
1130 Assert.AreEqual(false, flag, "#GS24 failed");
1133 [ExpectedException(typeof(ArgumentException))]
1134 public void GetSchemaTest25()
1136 String [] restrictions = new String[1];
1137 DataTable tab1 = conn.GetSchema("Mono", restrictions);