Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@ -0,0 +1,67 @@
2008-07-16 Gert Driesen <drieseng@users.sourceforge.net>
* OracleDataReader_GetDateTime.cs: Moved initialization of
connectionString to a setup method, as workaround for NUnit 2.2.0
bug with Assert.Ignore in ctor.
* OracleDataReader_NextResult.cs: Moved initialization of connection
to setup method, as workaround for NUnit 2.2.0 bug with Assert.Ignore
in ctor.
2008-06-27 Gert Driesen <drieseng@users.sourceforge.net>
* OracleDataReader_NextResult.cs: Ignore tests when not compiled for
JVM. Fixes buildbot test failures.
2006-10-19 Leszek Ciesielski <skolima@gmail.com>
* OracleDataReader_GetByte_I.cs:
* OracleDataReader_Read.cs:
* OracleDataReader_GetDataTypeName.cs:
* OracleDataReader_GetValue.cs:
* OracleDataReader_GetFloat_I.cs:
* OracleDataReader_NextResult.cs:
* OracleDataReader_GetString_I.cs:
* OracleDataReader_GetDouble_I.cs:
* OracleDataReader_RecordsAffected.cs:
* OracleDataReader_GetFieldType.cs:
* OracleDataReader_HasRows.cs:
* OracleDataReader_GetOrdinal.cs:
* OracleDataReader_GetTimeSpan_I.cs:
* OracleDataReader_GetBytes_IIBII.cs:
* OracleDataReader_GetDateTime.cs:
* OracleDataReader_Item.cs:
* OracleDataReader_GetValues.cs:
* OracleDataReader_GetChars.cs:
* OracleDataReader_GetInt16.cs:
* OracleDataReader_GetInt64.cs:
* OracleDataReader_Depth.cs:
* OracleDataReader_Close.cs:
* OracleDataReader_GetDecimal_I.cs:
* OracleDataReader_GetInt32_I.cs: Removed attribute NotWorking
2006-10-17 Leszek Ciesielski <skolima@gmail.com>
* OracleDataReader_GetByte_I.cs:
* OracleDataReader_Read.cs:
* OracleDataReader_GetDataTypeName.cs:
* OracleDataReader_GetValue.cs:
* OracleDataReader_GetFloat_I.cs:
* OracleDataReader_NextResult.cs:
* OracleDataReader_GetString_I.cs:
* OracleDataReader_GetDouble_I.cs:
* OracleDataReader_RecordsAffected.cs:
* OracleDataReader_GetFieldType.cs:
* OracleDataReader_HasRows.cs:
* OracleDataReader_GetOrdinal.cs:
* OracleDataReader_GetTimeSpan_I.cs:
* OracleDataReader_GetBytes_IIBII.cs:
* OracleDataReader_GetDateTime.cs:
* OracleDataReader_Item.cs:
* OracleDataReader_GetValues.cs:
* OracleDataReader_GetChars.cs:
* OracleDataReader_GetInt16.cs:
* OracleDataReader_GetInt64.cs:
* OracleDataReader_Depth.cs:
* OracleDataReader_Close.cs:
* OracleDataReader_GetDecimal_I.cs:
* OracleDataReader_GetInt32_I.cs: Set attribute NotWorking

View File

@ -0,0 +1,98 @@
//
// 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 OracleDataReader_Close : GHTBase
{
public static void Main()
{
OracleDataReader_Close tc = new OracleDataReader_Close();
Exception exp = null;
try
{
tc.BeginTest("DataReader.IsClosed");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
con.Open();
OracleCommand cmd = new OracleCommand("Select * From Customers", con);
OracleDataReader rdr = cmd.ExecuteReader();
try
{
BeginCase("before closing");
Compare(rdr.IsClosed ,false);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("after closing");
rdr.Close();
Compare(rdr.IsClosed ,true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
if (con.State == ConnectionState.Open) con.Close();
}
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
}
}

View File

@ -0,0 +1,99 @@
//
// 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 OracleDataReader_Depth : GHTBase
{
public static void Main()
{
OracleDataReader_Depth tc = new OracleDataReader_Depth();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_Depth");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
con.Open();
OracleCommand cmd = new OracleCommand("Select * From Customers", con);
OracleDataReader rdr = cmd.ExecuteReader();
try
{
BeginCase("Before execute");
Compare(rdr.Depth , 0);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("After execute");
rdr.Read();
Compare(rdr.Depth , 0);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
if (con.State == ConnectionState.Open) con.Close();
}
//public TestClass():base(true){}
//Activate this constructor to log Failures to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, false){}
//Activate this constructor to log All to a log file
//public TestClass(System.IO.TextWriter tw):base(tw, true){}
//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES
}
}

View File

@ -0,0 +1,101 @@
//
// 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 OracleDataReader_GetBoolean : ADONetTesterClass
{
public static void Main()
{
OracleDataReader_GetBoolean tc = new OracleDataReader_GetBoolean();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetBoolean");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
#if !JAVA
// PostgreSQL ODBC treats Type BOOL as String, so we don't run it on .NET
if ((ConnectedDataProvider.GetDbType(con) == DataBaseServer.PostgreSQL))
{
return;
}
#endif
//Do not test with oracle or DB2, because boolean does not exist in their types.
if ( (ConnectedDataProvider.GetDbType(con) == DataBaseServer.Oracle) || (ConnectedDataProvider.GetDbType(con) == DataBaseServer.DB2) )
{
return;
}
con.Open();
string fieldName = "t_bit";
if (ConnectedDataProvider.GetDbType(con) == DataBaseServer.PostgreSQL)
{
fieldName ="t_bool";
}
OracleCommand cmd = new OracleCommand("Select " + fieldName + " From TYPES_SIMPLE Where id = '0'",con);
OracleDataReader rdr = cmd.ExecuteReader();
rdr.Read();
try
{
BeginCase("GetBoolean true");
Boolean blnValue;
Compare(rdr.IsDBNull(0), false);
Compare("System.Boolean", rdr.GetValue(0).GetType().FullName);
blnValue = rdr.GetBoolean(0);
Compare(blnValue, true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
rdr.Close();
if (con.State == ConnectionState.Open) con.Close();
}
}
}

View File

@ -0,0 +1,143 @@
//
// 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 MonoTests.System.Data.Utils.Data;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleDataReader_GetByte_I : ADONetTesterClass
{
private Exception exp = null;
private int testTypesInvocations;
public static void Main()
{
OracleDataReader_GetByte_I tc = new OracleDataReader_GetByte_I();
tc.exp = null;
try
{
tc.BeginTest("OracleDataReader_GetByte_I");
tc.run();
}
catch(Exception ex)
{
tc.exp = ex;
}
finally
{
tc.EndTest(tc.exp);
}
}
[Test]
public void run()
{
DoTestTypes(ConnectedDataProvider.GetSimpleDbTypesParameters());
DoTestTypes(ConnectedDataProvider.GetExtendedDbTypesParameters());
}
public void DoTestTypes(DbTypeParametersCollection row)
{
testTypesInvocations++;
exp = null;
string rowId = "43967_" + this.testTypesInvocations.ToString();
OracleDataReader rdr = null;
OracleConnection con = null;
try
{
row.ExecuteInsert(rowId);
row.ExecuteSelectReader(rowId, out rdr, out con);
while (rdr.Read())
{
//Run over all the columns in the result set row.
//For each column, try to read it as a byte.
for (int i=0; i<row.Count; i++)
{
if (row[i].Value.GetType() == typeof(byte)) //The value in the result set should be a byte.
{
try
{
BeginCase(string.Format("Calling GetByte() on a field of dbtype {0}", row[i].DbTypeName));
byte retByte = rdr.GetByte(i);
Compare(row[i].Value, retByte);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
else //The value in the result set should NOT be byte. In this case an Invalid case exception should be thrown.
{
try
{
BeginCase(string.Format("Calling GetByte() on a field of dbtype {0}", row[i].DbTypeName));
byte retByte = rdr.GetByte(i);
ExpectedExceptionNotCaught("InvalidCastException");
}
catch (InvalidCastException ex)
{
ExpectedExceptionCaught(ex);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
}
}
}
finally
{
row.ExecuteDelete(rowId);
if ( (rdr != null) && (!rdr.IsClosed) )
{
rdr.Close();
}
if ( (con != null) && (con.State != ConnectionState.Closed) )
{
con.Close();
}
}
}
}
}

View File

@ -0,0 +1,141 @@
//
// 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 MonoTests.System.Data.Utils.Data;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleDataReader_GetBytes_IIBII : GHTBase
{
int testTypesInvocations;
Exception exp = null;
public static void Main()
{
OracleDataReader_GetBytes_IIBII tc = new OracleDataReader_GetBytes_IIBII();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetBytes_IIBII");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
DoTestTypes(ConnectedDataProvider.GetSimpleDbTypesParameters());
DoTestTypes(ConnectedDataProvider.GetExtendedDbTypesParameters());
}
public void DoTestTypes(DbTypeParametersCollection row)
{
testTypesInvocations++;
exp = null;
string rowId = "43966_" + this.testTypesInvocations.ToString();
OracleConnection con =null;
OracleDataReader rdr = null;
try
{
row.ExecuteInsert(rowId);
row.ExecuteSelectReader(rowId, out rdr, out con);
while (rdr.Read())
{
//Run over all the columns in the result set row.
//For each column, try to read it as a byte array.
for (int i=0; i<row.Count; i++)
{
if (row[i].Value.GetType() == typeof(byte[])) //The value in the result set should be a byte array.
{
try
{
BeginCase(string.Format("Calling GetBytes() on a field of dbtype {0}", row[i].DbTypeName));
byte[] origBytes = (byte[])row[i].Value;
byte[] retBytes = new byte[origBytes.Length];
rdr.GetBytes(i, 0, retBytes, 0, origBytes.Length);
Compare(origBytes, retBytes);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
else //The value in the result set should NOT be byte array. In this case an Invalid case exception should be thrown.
{
try
{
BeginCase(string.Format("Calling GetBytes() on a field of dbtype {0}", row[i].DbTypeName));
byte[] retBytes = new byte[1];
rdr.GetBytes(i, 0, retBytes, 0, 1);
ExpectedExceptionNotCaught("InvalidCastException");
}
catch (InvalidCastException ex)
{
ExpectedExceptionCaught(ex);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
}
}
}
finally
{
row.ExecuteDelete(rowId);
if (rdr != null && !rdr.IsClosed)
{
rdr.Close();
}
if (con != null && con.State != ConnectionState.Closed)
{
con.Close();
}
}
}
}
}

View File

@ -0,0 +1,119 @@
//
// 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 OracleDataReader_GetChars : ADONetTesterClass
{
OracleConnection con;
char [] Result;
[SetUp]
public void SetUp()
{
Exception exp = null;
BeginCase("Setup");
try
{
//prepare data
base.PrepareDataForTesting(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
Result = new char[100];
con.Open();
}
catch(Exception ex) {exp = ex;}
finally {EndCase(exp); exp = null;}
}
[TearDown]
public void TearDown()
{
if (con != null && con.State == ConnectionState.Open) con.Close();
}
public static void Main()
{
OracleDataReader_GetChars tc = new OracleDataReader_GetChars();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetChars");
tc.SetUp();
tc.run();
tc.TearDown();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
long rdrResults = 0;
OracleCommand cmd = new OracleCommand("Select LastName From Employees Where EmployeeID = 100", con);
OracleDataReader rdr = cmd.ExecuteReader();
rdr.Read();
//LastName should be "Last100"
try
{
BeginCase("check result length");
rdrResults = rdr.GetChars(0, 0, Result, 0, Result.Length);
Compare(rdrResults,(long)"Last100".Length );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("check result - char[0]");
Compare(Result[0] ,'L');
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("check result - char[last char index]");
Compare(Result["Last100".Length-1] ,'0');
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
}
}
}

View File

@ -0,0 +1,127 @@
//
// 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 OracleDataReader_GetDataTypeName : ADONetTesterClass
{
OracleConnection con;
OracleCommand cmd;
OracleDataReader rdr;
string typeName;
[SetUp]
public void SetUp()
{
Exception exp = null;
BeginCase("Setup");
try
{
con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
cmd = new OracleCommand("Select EmployeeID From Employees Where FirstName = 'Oved'", con);
cmd.CommandType = CommandType.Text;
con.Open();
rdr = cmd.ExecuteReader();
rdr.Read();
typeName = rdr.GetDataTypeName(0);
con.Close();
}
catch(Exception ex){exp = ex;}
finally {EndCase(exp);}
}
[TearDown]
public void TearDown()
{
}
public static void Main()
{
OracleDataReader_GetDataTypeName tc = new OracleDataReader_GetDataTypeName();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetDataTypeName");
tc.SetUp();
tc.run();
tc.TearDown();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
//make database specific test
switch (ConnectedDataProvider.GetDbType(con))
{
case DataBaseServer.SQLServer:
try
{
BeginCase("check type name");
Compare(typeName == "DBTYPE_I4" ,true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
break;
case DataBaseServer.Oracle:
try
{
BeginCase("check type name");
Compare(typeName == "DBTYPE_NUMERIC" || typeName == "NUMBER" ,true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
break;
case DataBaseServer.DB2:
try
{
BeginCase("check type name");
Compare(typeName == "DBTYPE_I4" || typeName == "INTEGER" ,true);
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
break;
case DataBaseServer.Unknown:
break;
}
}
}
}

View File

@ -0,0 +1,193 @@
//
// 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.Text;
using System.Data;
using System.Data.OracleClient;
using MonoTests.System.Data.Utils;
using MonoTests.System.Data.Utils.Data;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleDataReader_GetDateTime : ADONetTesterClass
{
private OracleConnection con;
private OracleCommand cmd;
private OracleDataReader rdr;
private string connectionString;
Exception exp;
[SetUp]
public void SetUp ()
{
connectionString = ConnectedDataProvider.ConnectionString;
}
[TearDown]
public void TearDown()
{
if (con != null && con.State == ConnectionState.Open)
con.Close();
}
public static void Main()
{
OracleDataReader_GetDateTime tc = new OracleDataReader_GetDateTime();
tc.SetUp ();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetDateTime");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
public void run()
{
SimpleValue();
MinDate();
}
[Test]
public void SimpleValue()
{
try
{
BeginCase("check simple value");
//prepare data
base.PrepareDataForTesting(connectionString);
con = new OracleConnection (connectionString);
con.Open();
cmd = new OracleCommand("Select BirthDate From Employees where EmployeeID = 100", con);
rdr = cmd.ExecuteReader();
rdr.Read();
DateTime dt = rdr.GetDateTime(0); //will be 1988-May-31 15:33:44
Compare(dt,new DateTime(1988,5,31,15,33,44,00));
} catch(Exception ex) {
exp = ex;
} finally {
EndCase(exp);
if (rdr != null && !rdr.IsClosed)
rdr.Close();
exp = null;
}
}
[Test]
public void MinDate()
{
BeginCase("Test Min date.");
exp = null;
string[] dateColumns;
DateTime[] expectedValues;
InitMinDates(out dateColumns, out expectedValues);
try
{
con = new OracleConnection(ConnectedDataProvider.ConnectionString);
cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText = BuildMinDateTimeSelectSql(dateColumns);
con.Open();
rdr = cmd.ExecuteReader();
Compare(true, rdr.HasRows);
bool b = rdr.Read();
for (int i=0; i<dateColumns.Length && i<expectedValues.Length; i++)
{
int j=-1;
j = rdr.GetOrdinal(dateColumns[i]);
//DateTime result = rdr.GetDateTime(j);
object result = rdr.GetValue(j);
Compare(result, expectedValues[i]);
}
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
if (rdr != null && !rdr.IsClosed)
{
rdr.Close();
}
if (con != null && con.State != ConnectionState.Closed)
{
con.Close();
}
}
}
private void InitMinDates(out string[] columns, out DateTime[] values)
{
switch(ConnectedDataProvider.GetDbType())
{
case DataBaseServer.SQLServer:
case DataBaseServer.Sybase:
columns = new string[] {"T_DATETIME", "T_SMALLDATETIME"};
values = new DateTime[] {new DateTime(1753, 01, 01,00, 00, 00), // 01/01/1753 00:00:00.000
new DateTime(1900, 01, 01,00, 00, 00)}; // 01/01/1900 00:00
break;
case DataBaseServer.Oracle:
columns = new string[] {"T_DATE"};
values = new DateTime[] {new DateTime(0001, 01, 01,00, 00, 00)}; //01-Jan-0001 12:00:00 AM
break;
case DataBaseServer.PostgreSQL:
columns = new string[] {"T_TIMESTAMP"};
values = new DateTime[] {new DateTime(1753, 01, 01,00, 00, 00)}; //01-Jan-1753 12:00:00 AM
break;
case DataBaseServer.DB2:
columns = new string[] {"T_DATE", "T_TIMESTAMP"};
values = new DateTime[] {new DateTime(0001, 01, 01), // 1/1/0001
new DateTime(0001, 01, 01, 00,00,00,0)}; // 1/1/0001 00:00:00.000
break;
default:
throw new ApplicationException(string.Format("GHT ERROR: Unknown DB server [{0}].",ConnectedDataProvider.GetDbType()));
}
}
private string BuildMinDateTimeSelectSql(string[] dateColumns)
{
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.Append("SELECT ");
foreach(string col in dateColumns)
{
sqlBuilder.Append(col + ", ");
}
sqlBuilder.Remove(sqlBuilder.Length - 2, 2);
sqlBuilder.Append(" FROM TYPES_EXTENDED WHERE ID='MIN'");
return sqlBuilder.ToString();
}
}
}

View File

@ -0,0 +1,222 @@
//
// 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 MonoTests.System.Data.Utils.Data;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleDataReader_GetDecimal_I : ADONetTesterClass
{
private int testTypesInvocations;
private Exception exp = null;
public static void Main()
{
OracleDataReader_GetDecimal_I tc = new OracleDataReader_GetDecimal_I();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetDecimal_I");
tc.run();
}
catch(Exception ex)
{
exp = ex;
}
finally
{
tc.EndTest(exp);
}
}
[Test]
public void run()
{
DoTestTypes(ConnectedDataProvider.GetSimpleDbTypesParameters());
DoTestTypes(ConnectedDataProvider.GetExtendedDbTypesParameters());
DoTestTextualFieldsThatContainNumbers(ConnectedDataProvider.GetSimpleDbTypesParameters());
DoTestTextualFieldsThatContainNumbers(ConnectedDataProvider.GetExtendedDbTypesParameters());
}
public void DoTestTypes(DbTypeParametersCollection row)
{
testTypesInvocations++;
exp = null;
string rowId = "43968_" + this.testTypesInvocations.ToString();
OracleDataReader rdr = null;
OracleConnection con = null;
try
{
row.ExecuteInsert(rowId);
row.ExecuteSelectReader(rowId, out rdr, out con);
while (rdr.Read())
{
//Run over all the columns in the result set row.
//For each column, try to read it as a Decimal.
for (int i=0; i<row.Count; i++)
{
if (row[i].Value.GetType() == typeof(decimal) ||
row[i].Value.GetType() == typeof(double)) //The value in the result set should be a Decimal.
{
try
{
BeginCase(string.Format("Calling GetDecimal() on a field of dbtype {0}", row[i].DbTypeName));
decimal retDecimal = rdr.GetDecimal(i);
Compare(row[i].Value, retDecimal);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
else //The value in the result set should NOT be Decimal. In this case an Invalid case exception should be thrown.
{
try
{
BeginCase(string.Format("Calling GetDecimal() on a field of dbtype {0}", row[i].DbTypeName));
decimal retDecimal = rdr.GetDecimal(i);
ExpectedExceptionNotCaught("InvalidCastException");
}
catch (InvalidCastException ex)
{
ExpectedExceptionCaught(ex);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
}
}
}
finally
{
row.ExecuteDelete(rowId);
if ( (rdr != null) && (!rdr.IsClosed) )
{
rdr.Close();
}
if ( (con != null) && (con.State != ConnectionState.Closed) )
{
con.Close();
}
}
}
public void DoTestTextualFieldsThatContainNumbers(DbTypeParametersCollection row)
{
//Leave only textual fields in the collection, and set their value to the string "10"
SetTextualFieldsWithNumericValues(ref row);
if (row.Count < 1)
{
return;
}
testTypesInvocations++;
exp = null;
string rowId = "43968_" + this.testTypesInvocations.ToString();
OracleDataReader rdr = null;
OracleConnection con = null;
try
{
row.ExecuteInsert(rowId);
row.ExecuteSelectReader(rowId, out rdr, out con);
while (rdr.Read())
{
//Run over all the columns in the result set row.
//For each column, try to read it as a Decimal.
//Because all the fields are textual, this should throw an InvalidCastException.
for (int i=0; i<row.Count; i++)
{
try
{
BeginCase(string.Format("Calling GetDecimal() on a textual field of dbtype {0} with value '{1}'", row[i].DbTypeName, row[i].Value));
decimal retDecimal = rdr.GetDecimal(i);
ExpectedExceptionNotCaught(typeof(InvalidCastException).FullName);
}
catch (InvalidCastException ex)
{
ExpectedExceptionCaught(ex);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
}
}
finally
{
row.ExecuteDelete(rowId);
if ( (rdr != null) && (!rdr.IsClosed) )
{
rdr.Close();
}
if ( (con != null) && (con.State != ConnectionState.Closed) )
{
con.Close();
}
}
}
private void SetTextualFieldsWithNumericValues(ref DbTypeParametersCollection row)
{
DbTypeParametersCollection newRow = new DbTypeParametersCollection(row.TableName);
foreach (DbTypeParameter current in row)
{
if (current.Value is string)
{
newRow.Add(current.DbTypeName, "10");
}
}
row = newRow;
}
}
}

View File

@ -0,0 +1,146 @@
//
// 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 MonoTests.System.Data.Utils.Data;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleDataReader_GetDouble_I : GHTBase
{
private Exception exp = null;
private int testTypesInvocations;
public static void Main()
{
OracleDataReader_GetDouble_I tc = new OracleDataReader_GetDouble_I();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetDouble_I");
tc.run();
}
catch(Exception ex)
{
tc.exp = ex;
}
finally
{
tc.EndTest(tc.exp);
}
}
[Test]
public void run()
{
DoTestTypes(ConnectedDataProvider.GetSimpleDbTypesParameters());
DoTestTypes(ConnectedDataProvider.GetExtendedDbTypesParameters());
}
public void DoTestTypes(DbTypeParametersCollection row)
{
testTypesInvocations++;
exp = null;
string rowId = "43969_" + this.testTypesInvocations.ToString();
OracleDataReader rdr = null;
OracleConnection con = null;
try
{
row.ExecuteInsert(rowId);
row.ExecuteSelectReader(rowId, out rdr, out con);
while (rdr.Read())
{
//Run over all the columns in the result set row.
//For each column, try to read it as a double.
for (int i=0; i<row.Count; i++)
{
if (row[i].Value.GetType() == typeof(double) ||
row[i].Value.GetType() == typeof(decimal)) //The value in the result set should be a double.
{
try
{
BeginCase(string.Format("Calling GetDouble() on a field of dbtype {0}", row[i].DbTypeName));
double retDouble = rdr.GetDouble(i);
Compare(row[i].Value, retDouble);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
else //The value in the result set should NOT be double. In this case an Invalid case exception should be thrown.
{
try
{
BeginCase(string.Format("Calling GetDouble() on a field of dbtype {0}", row[i].DbTypeName));
double retDouble = rdr.GetDouble(i);
ExpectedExceptionNotCaught("InvalidCastException");
}
catch (InvalidCastException ex)
{
ExpectedExceptionCaught(ex);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
}
}
}
finally
{
row.ExecuteDelete(rowId);
if ( (rdr != null) && (!rdr.IsClosed) )
{
rdr.Close();
}
if ( (con != null) && (con.State != ConnectionState.Closed) )
{
con.Close();
}
}
}
}
}

View File

@ -0,0 +1,103 @@
//
// 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 OracleDataReader_GetFieldType : ADONetTesterClass
{
OracleConnection con;
OracleCommand cmd;
OracleDataReader rdr;
[SetUp]
public void SetUp()
{
Exception exp = null;
BeginCase("Setup");
try
{
con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
con.Open();
cmd = new OracleCommand("Select OrderID, CustomerID, OrderDate From Orders", con);
rdr = cmd.ExecuteReader();
rdr.Read();
}
catch(Exception ex){exp = ex;}
finally {EndCase(exp);}
}
[TearDown]
public void TearDown()
{
if (con != null && con.State == ConnectionState.Open) con.Close();
}
public static void Main()
{
OracleDataReader_GetFieldType tc = new OracleDataReader_GetFieldType();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetFieldType");
tc.SetUp();
tc.run();
tc.TearDown();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
try
{
BeginCase("check type string");
Compare(rdr.GetFieldType(1).FullName,typeof(string).FullName );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("check type date");
Compare(rdr.GetFieldType(2).FullName,typeof(DateTime).FullName );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
}
}
}

View File

@ -0,0 +1,142 @@
//
// 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 MonoTests.System.Data.Utils.Data;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleDataReader_GetFloat_I : ADONetTesterClass
{
private Exception exp = null;
private int testTypesInvocations;
public static void Main()
{
OracleDataReader_GetFloat_I tc = new OracleDataReader_GetFloat_I();
tc.exp = null;
try
{
tc.BeginTest("OracleDataReader_GetFloat_I");
tc.run();
}
catch(Exception ex)
{
tc.exp = ex;
}
finally
{
tc.EndTest(tc.exp);
}
}
[Test]
public void run()
{
DoTestTypes(ConnectedDataProvider.GetSimpleDbTypesParameters());
DoTestTypes(ConnectedDataProvider.GetExtendedDbTypesParameters());
}
public void DoTestTypes(DbTypeParametersCollection row)
{
testTypesInvocations++;
exp = null;
string rowId = "43970_" + this.testTypesInvocations.ToString();
OracleDataReader rdr = null;
OracleConnection con = null;
try
{
row.ExecuteInsert(rowId);
row.ExecuteSelectReader(rowId, out rdr, out con);
while (rdr.Read())
{
//Run over all the columns in the result set row.
//For each column, try to read it as a float.
for (int i=0; i<row.Count; i++)
{
if (row[i].Value.GetType() == typeof(float) ||
row[i].Value.GetType() == typeof(double) ||
row[i].Value.GetType() == typeof(decimal)) { //The value in the result set should be a float.
try
{
BeginCase(string.Format("Calling GetFloat() on a field of dbtype {0}", row[i].DbTypeName));
float retFloat = rdr.GetFloat(i);
Compare(row[i].Value, retFloat);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
else //The value in the result set should NOT be float. In this case an Invalid case exception should be thrown.
{
try
{
BeginCase(string.Format("Calling GetFloat() on a field of dbtype {0}", row[i].DbTypeName));
float retFloat = rdr.GetFloat(i);
ExpectedExceptionNotCaught("InvalidCastException");
}
catch (InvalidCastException ex)
{
ExpectedExceptionCaught(ex);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
}
}
}
finally
{
row.ExecuteDelete(rowId);
if ( (rdr != null) && (!rdr.IsClosed) )
{
rdr.Close();
}
if ( (con != null) && (con.State != ConnectionState.Closed) )
{
con.Close();
}
}
}
}
}

View File

@ -0,0 +1,171 @@
//
// 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 MonoTests.System.Data.Utils.Data;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleDataReader_GetGuiid_I : ADONetTesterClass
{
private const string GUID_COLUMN_NAME = "T_UNIQUEIDENTIFIER";
private const string GUID_TABLE_NAME = ConnectedDataProvider.SPECIFIC_TYPES_TABLE_NAME;
private const string TEST_GUID_STRING = "239A3C5E-8D41-11D1-B675-00C04FA3C554";
public static void Main()
{
OracleDataReader_GetGuiid_I tc = new OracleDataReader_GetGuiid_I();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetGuiid_I");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
public void run()
{
TestUsingSQLTextOnly();
TestUsingParametersArray();
}
[Test]
public void TestUsingSQLTextOnly()
{
//Only apply to MSSQL
if ( (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer)) {
return;
}
Exception exp = null;
OracleDataReader rdr = null;
OracleConnection con = null;
OracleCommand cmdDelete = null;
try
{
BeginCase("Test using SQL text only.");
string rowId = "43973_" + TestCaseNumber.ToString();
string insertText = string.Format("INSERT INTO {0} (ID, {1}) VALUES ('{2}', '{{{3}}}')", GUID_TABLE_NAME, GUID_COLUMN_NAME, rowId, TEST_GUID_STRING);
string selectText = string.Format("SELECT {0} FROM {1} WHERE ID='{2}'", GUID_COLUMN_NAME, GUID_TABLE_NAME, rowId);
string deleteText = string.Format("DELETE FROM {0} WHERE ID='{1}'", GUID_TABLE_NAME, rowId);
con = new OracleConnection(ConnectedDataProvider.ConnectionString);
OracleCommand cmdInsert = new OracleCommand(insertText, con);
OracleCommand cmdSelect = new OracleCommand(selectText, con);
cmdDelete = new OracleCommand(deleteText, con);
con.Open();
cmdInsert.ExecuteNonQuery();
rdr = cmdSelect.ExecuteReader();
rdr.Read();
Guid guidValue = rdr.GetGuid (0);
Guid origGuid = new Guid(TEST_GUID_STRING);
Compare(guidValue, origGuid);
}
catch(Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
if ( (rdr != null) && (!rdr.IsClosed) )
{
rdr.Close();
}
if (cmdDelete != null)
{
cmdDelete.ExecuteNonQuery();
}
if ( (con != null) && (con.State != ConnectionState.Closed) )
{
con.Close();
}
}
}
[Test]
public void TestUsingParametersArray()
{
//Only apply to MSSQL
if ( (ConnectedDataProvider.GetDbType() != DataBaseServer.SQLServer))
{
return;
}
Exception exp = null;
OracleDataReader rdr = null;
OracleConnection con = null;
DbTypeParametersCollection row = new DbTypeParametersCollection(GUID_TABLE_NAME);
string rowId = string.Empty;
try
{
BeginCase("Test using parameters array");
rowId = "43973_" + TestCaseNumber.ToString();
row.Add("UNIQUEIDENTIFIER", new Guid(TEST_GUID_STRING));
row.ExecuteInsert(rowId);
row.ExecuteSelectReader(rowId, out rdr, out con);
rdr.Read();
Guid guidValue = rdr.GetGuid (0);
Compare(guidValue, row[GUID_COLUMN_NAME].Value);
}
catch(Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
if ( (rdr != null) && (!rdr.IsClosed) )
{
rdr.Close();
}
if (rowId != String.Empty)
{
row.ExecuteDelete(rowId);
}
if ( (con != null) && (con.State != ConnectionState.Closed) )
{
con.Close();
}
}
}
}
}

View File

@ -0,0 +1,144 @@
//
// 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 MonoTests.System.Data.Utils.Data;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleDataReader_GetInt16 : ADONetTesterClass
{
private Exception exp = null;
private int testTypesInvocations;
public static void Main()
{
OracleDataReader_GetInt16 tc = new OracleDataReader_GetInt16();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetInt16_I");
tc.run();
}
catch(Exception ex)
{
tc.exp = ex;
}
finally
{
tc.EndTest(tc.exp);
}
}
[Test]
public void run()
{
DoTestTypes(ConnectedDataProvider.GetSimpleDbTypesParameters());
DoTestTypes(ConnectedDataProvider.GetExtendedDbTypesParameters());
}
public void DoTestTypes(DbTypeParametersCollection row)
{
testTypesInvocations++;
exp = null;
string rowId = "43971_" + this.testTypesInvocations.ToString();
OracleDataReader rdr = null;
OracleConnection con = null;
try
{
row.ExecuteInsert(rowId);
row.ExecuteSelectReader(rowId, out rdr, out con);
while (rdr.Read())
{
//Run over all the columns in the result set row.
//For each column, try to read it as a Int16.
for (int i=0; i<row.Count; i++)
{
if (row[i].Value.GetType() == typeof(Int16)) //The value in the result set should be a Int16.
{
try
{
BeginCase(string.Format("Calling GetInt16() on a field of dbtype {0}", row[i].DbTypeName));
Int16 retInt16 = rdr.GetInt16(i);
Compare(row[i].Value, retInt16);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
else //The value in the result set should NOT be Int16. In this case an Invalid case exception should be thrown.
{
try
{
BeginCase(string.Format("Calling GetInt16() on a field of dbtype {0}", row[i].DbTypeName));
Int16 retInt16 = rdr.GetInt16(i);
ExpectedExceptionNotCaught("InvalidCastException");
}
catch (InvalidCastException ex)
{
ExpectedExceptionCaught(ex);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
}
}
}
finally
{
row.ExecuteDelete(rowId);
if ( (rdr != null) && (!rdr.IsClosed) )
{
rdr.Close();
}
if ( (con != null) && (con.State != ConnectionState.Closed) )
{
con.Close();
}
}
}
}
}

View File

@ -0,0 +1,144 @@
//
// 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 MonoTests.System.Data.Utils.Data;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleDataReader_GetInt32_I : ADONetTesterClass
{
private Exception exp = null;
private int testTypesInvocations;
public static void Main()
{
OracleDataReader_GetInt32_I tc = new OracleDataReader_GetInt32_I();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetInt32_I");
tc.run();
}
catch(Exception ex)
{
tc.exp = ex;
}
finally
{
tc.EndTest(tc.exp);
}
}
[Test]
public void run()
{
DoTestTypes(ConnectedDataProvider.GetSimpleDbTypesParameters());
DoTestTypes(ConnectedDataProvider.GetExtendedDbTypesParameters());
}
public void DoTestTypes(DbTypeParametersCollection row)
{
testTypesInvocations++;
exp = null;
string rowId = "13286_" + this.testTypesInvocations.ToString();
OracleDataReader rdr = null;
OracleConnection con = null;
try
{
row.ExecuteInsert(rowId);
row.ExecuteSelectReader(rowId, out rdr, out con);
while (rdr.Read())
{
//Run over all the columns in the result set row.
//For each column, try to read it as a Int32.
for (int i=0; i<row.Count; i++)
{
if (row[i].Value.GetType() == typeof(Int32) ||
row[i].Value.GetType() == typeof(double) ||
row[i].Value.GetType() == typeof(decimal)) { //The value in the result set should be a Int32.
try
{
BeginCase(string.Format("Calling GetInt32() on a field of dbtype {0}", row[i].DbTypeName));
Int32 retInt32 = rdr.GetInt32(i);
Compare(Convert.ToInt32(row[i].Value), retInt32);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
else //The value in the result set should NOT be Int32. In this case an Invalid case exception should be thrown.
{
try
{
BeginCase(string.Format("Calling GetInt32() on a field of dbtype {0}", row[i].DbTypeName));
Int32 retInt32 = rdr.GetInt32(i);
ExpectedExceptionNotCaught("InvalidCastException");
}
catch (InvalidCastException ex)
{
ExpectedExceptionCaught(ex);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
}
}
}
finally
{
row.ExecuteDelete(rowId);
if ( (rdr != null) && (!rdr.IsClosed) )
{
rdr.Close();
}
if ( (con != null) && (con.State != ConnectionState.Closed) )
{
con.Close();
}
}
}
}
}

View File

@ -0,0 +1,146 @@
//
// 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 MonoTests.System.Data.Utils.Data;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleDataReader_GetInt64 : ADONetTesterClass
{
private Exception exp = null;
private int testTypesInvocations;
public static void Main()
{
OracleDataReader_GetInt64 tc = new OracleDataReader_GetInt64();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetInt64_I");
tc.run();
}
catch(Exception ex)
{
tc.exp = ex;
}
finally
{
tc.EndTest(tc.exp);
}
}
[Test]
public void run()
{
DoTestTypes(ConnectedDataProvider.GetSimpleDbTypesParameters());
DoTestTypes(ConnectedDataProvider.GetExtendedDbTypesParameters());
}
public void DoTestTypes(DbTypeParametersCollection row)
{
testTypesInvocations++;
exp = null;
string rowId = "43972_" + this.testTypesInvocations.ToString();
OracleDataReader rdr = null;
OracleConnection con = null;
try
{
row.ExecuteInsert(rowId);
row.ExecuteSelectReader(rowId, out rdr, out con);
while (rdr.Read())
{
//Run over all the columns in the result set row.
//For each column, try to read it as a Int64.
for (int i=0; i<row.Count; i++)
{
if (row[i].Value.GetType() == typeof(Int64) ||
row[i].Value.GetType() == typeof(double) ||
row[i].Value.GetType() == typeof(decimal)) { //The value in the result set should be a Int64.
try
{
BeginCase(string.Format("Calling GetInt64() on a field of dbtype {0}", row[i].DbTypeName));
Int64 retInt64 = rdr.GetInt64(i);
Compare(Convert.ToInt64(row[i].Value), retInt64);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
else //The value in the result set should NOT be Int64. In this case an Invalid case exception should be thrown.
{
try
{
BeginCase(string.Format("Calling GetInt64() on a field of dbtype {0}", row[i].DbTypeName));
Int64 retInt64 = rdr.GetInt64(i);
ExpectedExceptionNotCaught("InvalidCastException");
}
catch (InvalidCastException ex)
{
ExpectedExceptionCaught(ex);
}
catch (Exception ex)
{
exp = ex;
}
finally
{
EndCase(exp);
exp = null;
}
}
}
}
}
finally
{
row.ExecuteDelete(rowId);
if ( (rdr != null) && (!rdr.IsClosed) )
{
rdr.Close();
}
if ( (con != null) && (con.State != ConnectionState.Closed) )
{
con.Close();
}
}
}
}
}

View File

@ -0,0 +1,100 @@
//
// 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 OracleDataReader_GetName_I : GHTBase
{
public static void Main()
{
OracleDataReader_GetName_I tc = new OracleDataReader_GetName_I();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_NextResult");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
#if !TARGET_JVM
[Category("NotWorking")]
#endif
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
OracleCommand cmd = new OracleCommand("Customers", con);
cmd.CommandType = CommandType.TableDirect;
con.Open();
OracleDataReader rdr = cmd.ExecuteReader();
rdr.Read();
try
{
BeginCase("GetName field 0");
string str = rdr.GetName(0);
Compare(str.ToUpper(),"CUSTOMERID" );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("GetName last field ");
string str = rdr.GetName(rdr.FieldCount -1);
Compare(str.ToUpper(),"FAX" );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
if (con.State == ConnectionState.Open) con.Close();
}
}
}

View File

@ -0,0 +1,88 @@
//
// 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 OracleDataReader_GetOrdinal : ADONetTesterClass
{
public static void Main()
{
OracleDataReader_GetOrdinal tc = new OracleDataReader_GetOrdinal();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetOrdinal");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
con.Open();
OracleCommand cmd = new OracleCommand("Select * From Customers", con);
OracleDataReader rdr = cmd.ExecuteReader();
try
{
BeginCase("column REGION ordinal");
Compare(rdr.GetOrdinal("REGION"),6 );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("column not exists");
try
{
int i = rdr.GetOrdinal("blabla");
}
catch (Exception ex) {exp=ex;}
Compare(exp.GetType().FullName,typeof(IndexOutOfRangeException).FullName);
exp=null;
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
if (con.State == ConnectionState.Open) con.Close();
}
}
}

View File

@ -0,0 +1,209 @@
//
// 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]
class TestId13294 : GHTBase
{
public static void Main()
{
TestId13294 tc = new TestId13294();
Exception exp = null;
try
{
tc.BeginTest("OracleDataReader_GetSchemaTable");
tc.run();
}
catch(Exception ex){exp = ex;}
finally {tc.EndTest(exp);}
}
[Test]
public void run()
{
Exception exp = null;
OracleConnection con = new OracleConnection(MonoTests.System.Data.Utils.ConnectedDataProvider.ConnectionString);
con.Open();
OracleCommand cmd = new OracleCommand("Select * From Orders", con);
OracleDataReader rdr = cmd.ExecuteReader();
DataTable tbl = rdr.GetSchemaTable();
//check that all the columns properties (according to .Net) exists (GH give more properties)
try
{
BeginCase("ColumnName");
Compare(tbl.Columns.Contains("ColumnName"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("ColumnOrdinal");
Compare(tbl.Columns.Contains("ColumnOrdinal"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("ColumnSize");
Compare(tbl.Columns.Contains("ColumnSize"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("NumericPrecision");
Compare(tbl.Columns.Contains("NumericPrecision"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("NumericScale");
Compare(tbl.Columns.Contains("NumericScale"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("DataType");
Compare(tbl.Columns.Contains("DataType"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("ProviderType");
Compare(tbl.Columns.Contains("ProviderType"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("IsLong");
Compare(tbl.Columns.Contains("IsLong"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("AllowDBNull");
Compare(tbl.Columns.Contains("AllowDBNull"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("IsReadOnly");
Compare(tbl.Columns.Contains("IsReadOnly"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("IsRowVersion");
Compare(tbl.Columns.Contains("IsRowVersion"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("IsUnique");
Compare(tbl.Columns.Contains("IsUnique"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("IsKey");
Compare(tbl.Columns.Contains("IsKey"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("IsAutoIncrement");
Compare(tbl.Columns.Contains("IsAutoIncrement"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("BaseSchemaName");
Compare(tbl.Columns.Contains("BaseSchemaName"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("BaseTableName");
Compare(tbl.Columns.Contains("BaseTableName"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
try
{
BeginCase("BaseColumnName");
Compare(tbl.Columns.Contains("BaseColumnName"),true );
}
catch(Exception ex){exp = ex;}
finally{EndCase(exp); exp = null;}
if (con.State == ConnectionState.Open) con.Close();
}
}
}

Some files were not shown because too many files have changed in this diff Show More