OleDbDataReader_GetSchemaTable.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. //
  2. // Copyright (c) 2006 Mainsoft Co.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. using System;
  24. using System.Data;
  25. using System.Data.OleDb;
  26. using MonoTests.System.Data.Utils;
  27. using NUnit.Framework;
  28. namespace MonoTests.System.Data.OleDb
  29. {
  30. [TestFixture]
  31. class TestId13294 : GHTBase
  32. {
  33. public static void Main()
  34. {
  35. TestId13294 tc = new TestId13294();
  36. Exception exp = null;
  37. try
  38. {
  39. tc.BeginTest("OleDbDataReader_GetSchemaTable");
  40. tc.run();
  41. }
  42. catch(Exception ex){exp = ex;}
  43. finally {tc.EndTest(exp);}
  44. }
  45. [Test]
  46. public void run()
  47. {
  48. Exception exp = null;
  49. OleDbConnection con = new OleDbConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
  50. con.Open();
  51. OleDbCommand cmd = new OleDbCommand("Select * From Orders", con);
  52. OleDbDataReader rdr = cmd.ExecuteReader();
  53. DataTable tbl = rdr.GetSchemaTable();
  54. //check that all the columns properties (according to .Net) exists (GH give more properties)
  55. try
  56. {
  57. BeginCase("ColumnName");
  58. Compare(tbl.Columns.Contains("ColumnName"),true );
  59. }
  60. catch(Exception ex){exp = ex;}
  61. finally{EndCase(exp); exp = null;}
  62. try
  63. {
  64. BeginCase("ColumnOrdinal");
  65. Compare(tbl.Columns.Contains("ColumnOrdinal"),true );
  66. }
  67. catch(Exception ex){exp = ex;}
  68. finally{EndCase(exp); exp = null;}
  69. try
  70. {
  71. BeginCase("ColumnSize");
  72. Compare(tbl.Columns.Contains("ColumnSize"),true );
  73. }
  74. catch(Exception ex){exp = ex;}
  75. finally{EndCase(exp); exp = null;}
  76. try
  77. {
  78. BeginCase("NumericPrecision");
  79. Compare(tbl.Columns.Contains("NumericPrecision"),true );
  80. }
  81. catch(Exception ex){exp = ex;}
  82. finally{EndCase(exp); exp = null;}
  83. try
  84. {
  85. BeginCase("NumericScale");
  86. Compare(tbl.Columns.Contains("NumericScale"),true );
  87. }
  88. catch(Exception ex){exp = ex;}
  89. finally{EndCase(exp); exp = null;}
  90. try
  91. {
  92. BeginCase("DataType");
  93. Compare(tbl.Columns.Contains("DataType"),true );
  94. }
  95. catch(Exception ex){exp = ex;}
  96. finally{EndCase(exp); exp = null;}
  97. try
  98. {
  99. BeginCase("ProviderType");
  100. Compare(tbl.Columns.Contains("ProviderType"),true );
  101. }
  102. catch(Exception ex){exp = ex;}
  103. finally{EndCase(exp); exp = null;}
  104. try
  105. {
  106. BeginCase("IsLong");
  107. Compare(tbl.Columns.Contains("IsLong"),true );
  108. }
  109. catch(Exception ex){exp = ex;}
  110. finally{EndCase(exp); exp = null;}
  111. try
  112. {
  113. BeginCase("AllowDBNull");
  114. Compare(tbl.Columns.Contains("AllowDBNull"),true );
  115. }
  116. catch(Exception ex){exp = ex;}
  117. finally{EndCase(exp); exp = null;}
  118. try
  119. {
  120. BeginCase("IsReadOnly");
  121. Compare(tbl.Columns.Contains("IsReadOnly"),true );
  122. }
  123. catch(Exception ex){exp = ex;}
  124. finally{EndCase(exp); exp = null;}
  125. try
  126. {
  127. BeginCase("IsRowVersion");
  128. Compare(tbl.Columns.Contains("IsRowVersion"),true );
  129. }
  130. catch(Exception ex){exp = ex;}
  131. finally{EndCase(exp); exp = null;}
  132. try
  133. {
  134. BeginCase("IsUnique");
  135. Compare(tbl.Columns.Contains("IsUnique"),true );
  136. }
  137. catch(Exception ex){exp = ex;}
  138. finally{EndCase(exp); exp = null;}
  139. try
  140. {
  141. BeginCase("IsKey");
  142. Compare(tbl.Columns.Contains("IsKey"),true );
  143. }
  144. catch(Exception ex){exp = ex;}
  145. finally{EndCase(exp); exp = null;}
  146. try
  147. {
  148. BeginCase("IsAutoIncrement");
  149. Compare(tbl.Columns.Contains("IsAutoIncrement"),true );
  150. }
  151. catch(Exception ex){exp = ex;}
  152. finally{EndCase(exp); exp = null;}
  153. try
  154. {
  155. BeginCase("BaseSchemaName");
  156. Compare(tbl.Columns.Contains("BaseSchemaName"),true );
  157. }
  158. catch(Exception ex){exp = ex;}
  159. finally{EndCase(exp); exp = null;}
  160. try
  161. {
  162. BeginCase("BaseTableName");
  163. Compare(tbl.Columns.Contains("BaseTableName"),true );
  164. }
  165. catch(Exception ex){exp = ex;}
  166. finally{EndCase(exp); exp = null;}
  167. try
  168. {
  169. BeginCase("BaseColumnName");
  170. Compare(tbl.Columns.Contains("BaseColumnName"),true );
  171. }
  172. catch(Exception ex){exp = ex;}
  173. finally{EndCase(exp); exp = null;}
  174. if (con.State == ConnectionState.Open) con.Close();
  175. }
  176. }
  177. }