2 // Copyright (c) 2006 Mainsoft Co.
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:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
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.
26 using System.Data.OleDb;
28 using MonoTests.System.Data.Utils;
31 using NUnit.Framework;
33 namespace MonoTests.System.Data.OleDb
36 public class OleDbCommandBuilder_DeriveParameters_O : GHTBase
49 con = new OleDbConnection(ConnectedDataProvider.ConnectionString);
51 cmd = new OleDbCommand("", con);
52 Compare("Setup", "Setup");
54 catch(Exception ex) {exp = ex;}
55 finally {EndCase(exp); exp = null;}
59 public void TearDown()
63 if (con.State == ConnectionState.Open) con.Close();
67 public static void Main()
69 OleDbCommandBuilder_DeriveParameters_O tc = new OleDbCommandBuilder_DeriveParameters_O();
72 tc.BeginTest("OleDbCommandBuilder_DeriveParameters_O");
94 public void RetrieveParameters()
100 BeginCase("retrieve parameters");
102 if (ConnectedDataProvider.GetDbType(con) == DataBaseServer.DB2)
104 this.Skip("Not Implemented on DB2.");
108 switch (ConnectedDataProvider.GetDbType(con))
110 // case MonoTests.Utils.DataBaseServer.PostgreSQL:
111 // cmd = new OleDbCommand("GH_MULTIRECORDSETS('a','b','c')", con);
114 cmd = new OleDbCommand("GH_MultiRecordSets", con);
118 cmd.CommandType = CommandType.StoredProcedure;
119 OleDbCommandBuilder.DeriveParameters(cmd);
121 switch (ConnectedDataProvider.GetDbType(con))
123 case DataBaseServer.SQLServer:
124 case DataBaseServer.Sybase:
125 Compare(cmd.Parameters.Count, 1);
126 Compare(cmd.Parameters[0].Direction, ParameterDirection.ReturnValue);
127 Compare(cmd.Parameters[0].ParameterName, "RETURN_VALUE");
130 case DataBaseServer.Oracle:
131 Compare(cmd.Parameters.Count, 3);
132 Compare(cmd.Parameters[0].Direction, ParameterDirection.Output);
133 Compare(cmd.Parameters[1].Direction, ParameterDirection.Output);
134 Compare(cmd.Parameters[2].Direction, ParameterDirection.Output);
135 Compare(cmd.Parameters[0].ParameterName, "RCT_EMPLOYEES");
138 case DataBaseServer.PostgreSQL:
139 Compare(cmd.Parameters.Count, 1);
140 Compare(cmd.Parameters[0].Direction, ParameterDirection.ReturnValue);
141 Compare(cmd.Parameters[0].ParameterName, "returnValue");
145 throw new ApplicationException(string.Format("GHT: Test not implemented for DB type {0}", ConnectedDataProvider.GetDbType(con)));