IDBConnection_For_Oracle.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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.OracleClient ;
  26. using MonoTests.System.Data.Utils;
  27. using NUnit.Framework;
  28. namespace MonoTests.System.Data.OracleClient
  29. {
  30. [TestFixture]
  31. class IDBConnection_For_Oracle : GHTBase
  32. {
  33. string _ConnectionString = "";
  34. [SetUp]
  35. public void SetUp()
  36. {
  37. try
  38. {
  39. _ConnectionString = MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString;
  40. }
  41. catch(Exception ex)
  42. {
  43. EndCase(ex);
  44. }
  45. }
  46. [TearDown]
  47. public void TearDown()
  48. {
  49. }
  50. public static void Main()
  51. {
  52. IDBConnection_For_Oracle tc = new IDBConnection_For_Oracle();
  53. Exception exp = null;
  54. try
  55. {
  56. tc.BeginTest("IDBConnection_For_Oracle");
  57. tc.SetUp();
  58. tc.run();
  59. tc.TearDown();
  60. }
  61. catch(Exception ex){exp = ex;}
  62. finally {tc.EndTest(exp);}
  63. }
  64. [Test]
  65. public void run()
  66. {
  67. Exception exp = null;
  68. IDbConnection ICon = new OracleConnection();
  69. try
  70. {
  71. BeginCase("check IDbConnection is null");
  72. Compare(ICon != null, true);
  73. }
  74. catch(Exception ex){exp = ex;}
  75. finally{EndCase(exp); exp = null;}
  76. try
  77. {
  78. BeginCase("check IDbConnection type");
  79. Compare(ICon.GetType().FullName ,typeof(OracleConnection).FullName);
  80. }
  81. catch(Exception ex){exp = ex;}
  82. finally{EndCase(exp); exp = null;}
  83. ICon = new OracleConnection(_ConnectionString);
  84. try
  85. {
  86. BeginCase("check IDbConnection connection string");
  87. Compare(ICon.ConnectionString ,_ConnectionString);
  88. }
  89. catch(Exception ex){exp = ex;}
  90. finally{EndCase(exp); exp = null;}
  91. try
  92. {
  93. BeginCase("check IDbConnection ConnectionTimeout");
  94. Compare(ICon.ConnectionTimeout ,15);
  95. }
  96. catch(Exception ex){exp = ex;}
  97. finally{EndCase(exp); exp = null;}
  98. try
  99. {
  100. BeginCase("check IDbConnection state - closed");
  101. Compare(ICon.State ,ConnectionState.Closed);
  102. }
  103. catch(Exception ex){exp = ex;}
  104. finally{EndCase(exp); exp = null;}
  105. ICon.Open();
  106. try
  107. {
  108. BeginCase("check IDbConnection - open");
  109. Compare(ICon.State ,ConnectionState.Open );
  110. }
  111. catch(Exception ex){exp = ex;}
  112. finally{EndCase(exp); exp = null;}
  113. try
  114. {
  115. BeginCase("check IDbConnection CreateCommand");
  116. IDbCommand cmd = ICon.CreateCommand();
  117. Compare(cmd.GetType().FullName ,typeof(OracleCommand).FullName);
  118. }
  119. catch(Exception ex){exp = ex;}
  120. finally{EndCase(exp); exp = null;}
  121. if (ICon.State == ConnectionState.Open) ICon.Close();
  122. }
  123. }
  124. }