| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- //
- // Copyright (c) 2006 Mainsoft Co.
- //
- // Permission is hereby granted, free of charge, to any person obtaining
- // a copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to
- // permit persons to whom the Software is furnished to do so, subject to
- // the following conditions:
- //
- // The above copyright notice and this permission notice shall be
- // included in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- //
- using System;
- using System.Data;
- using System.Data.OracleClient;
- using MonoTests.System.Data.Utils;
- using NUnit.Framework;
- namespace MonoTests.System.Data.OracleClient
- {
- [TestFixture]
- public class OracleCommandBuilder_DeriveParameters_O : GHTBase
- {
- OracleConnection con;
- OracleCommand cmd;
- Exception exp = null;
- [SetUp]
- public void SetUp()
- {
- exp=null;
- BeginCase("Setup");
- try
- {
- con = new OracleConnection(ConnectedDataProvider.ConnectionString);
- con.Open();
- cmd = new OracleCommand("", con);
- Compare("Setup", "Setup");
- }
- catch(Exception ex) {exp = ex;}
- finally {EndCase(exp); exp = null;}
- }
- [TearDown]
- public void TearDown()
- {
- if (con != null)
- {
- if (con.State == ConnectionState.Open) con.Close();
- }
- }
- public static void Main()
- {
- OracleCommandBuilder_DeriveParameters_O tc = new OracleCommandBuilder_DeriveParameters_O();
- try
- {
- tc.BeginTest("OracleCommandBuilder_DeriveParameters_O");
- tc.SetUp();
- tc.run();
- tc.TearDown();
- }
- catch(Exception ex)
- {
- tc.exp = ex;
- }
- finally
- {
- tc.EndTest(tc.exp);
- }
- }
- public void run()
- {
- RetrieveParameters();
- }
- [Test]
- public void RetrieveParameters()
- {
- exp = null;
- try
- {
- BeginCase("retrieve parameters");
-
- if (ConnectedDataProvider.GetDbType(con) == DataBaseServer.DB2)
- {
- this.Skip("Not Implemented on DB2.");
- return;
- }
- switch (ConnectedDataProvider.GetDbType(con))
- {
- // case MonoTests.Utils.DataBaseServer.PostgreSQL:
- // cmd = new OracleCommand("GH_MULTIRECORDSETS('a','b','c')", con);
- // break;
- default:
- cmd = new OracleCommand("GH_MultiRecordSets", con);
- break;
- }
-
- cmd.CommandType = CommandType.StoredProcedure;
- OracleCommandBuilder.DeriveParameters(cmd);
- switch (ConnectedDataProvider.GetDbType(con))
- {
- case DataBaseServer.SQLServer:
- case DataBaseServer.Sybase:
- Compare(cmd.Parameters.Count, 1);
- Compare(cmd.Parameters[0].Direction, ParameterDirection.ReturnValue);
- Compare(cmd.Parameters[0].ParameterName, "RETURN_VALUE");
- break;
-
- case DataBaseServer.Oracle:
- Compare(cmd.Parameters.Count, 3);
- Compare(cmd.Parameters[0].Direction, ParameterDirection.Output);
- Compare(cmd.Parameters[1].Direction, ParameterDirection.Output);
- Compare(cmd.Parameters[2].Direction, ParameterDirection.Output);
- Compare(cmd.Parameters[0].ParameterName, "RCT_EMPLOYEES");
- break;
- case DataBaseServer.PostgreSQL:
- Compare(cmd.Parameters.Count, 1);
- Compare(cmd.Parameters[0].Direction, ParameterDirection.ReturnValue);
- Compare(cmd.Parameters[0].ParameterName, "returnValue");
- break;
- default:
- throw new ApplicationException(string.Format("GHT: Test not implemented for DB type {0}", ConnectedDataProvider.GetDbType(con)));
- }
- }
- catch(Exception ex)
- {
- exp = ex;
- }
- finally
- {
- EndCase(exp);
- exp = null;
- }
- }
- }
- }
|