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,76 @@
2010-01-15 Jonathan Pobst <monkey@jpobst.com>
* OracleParameterTest.cs: Mark test ParamSize_424908_SizeNotSetError
as not working. Bug filed: #571218.
2009-09-25 Veerapuram Varadhan <vvaradhan@novell.com>
* OracleParameterTest.cs: Mark tests for bug #424908 as working.
2009-06-04 Veerapuram Varadhan <vvaradhan@novell.com>
* OracleParameterTest.cs: Enable Constructor2 test for 2.0
profile and misc profile specific fixes.
2009-06-03 Veerapuram Varadhan <vvaradhan@novell.com>
* OracleParameterTest.cs: Mark tests for bug #424908 as NotWorking
as it requires some more thorough debugging.
2009-06-03 Veerapuram Varadhan <vvaradhan@novell.com>
* OracleParameterTest.cs: Use the member variables for
connection/command for executing the tests.
2009-05-15 Veerapuram Varadhan <vvaradhan@novell.com>
* OracleParameterTest.cs: Added tests corresponding to #424908
2008-05-07 Gert Driesen <drieseng@users.sourceforge.net>
* OracleDataAdapterTest.cs: Added ctor and basic property tests.
* OracleParameterCollectionTest.cs: Added tests for Clear,Count,Add,
Add,AddRange,Contains,indexers,IndexOf,Insert,Remove and RemoveAt.
* OracleCommandTest.cs: Added tests for ctors and CommandText,
CommandTimeout, ConnectionTimeout and Connection.
* OracleConnectionTest.cs: Added tests for ConnectionString and
ConnectionTimeout.
* OracleParameterTest.cs: Allow for disconnected tests. Added basic
ctor tests and test for ParameterName.
* OracleTimeSpanTest.cs: Added ctor tests. Added tests for IsNull,
MaxValue, MinValue, Null and ToString.
2007-05-25 Amit Biswas <amit@amitbiswas.com>
* OracleParameterCollectionTest.cs: Created the class OracleParameterCollectionTest and added
tests for the properties IsFixedSize, IsReadOnly and IsSynchronized.
2007-02-13 Leszek Ciesielski <skolima@gmail.com>
* OracleParameterTest.cs: Simple tests for handling OracleString,
OracleDateTime and OracleNumber
2006-10-17 Leszek Ciesielski <skoliima@gmail.com>
* OracleLobTest.cs:
* OracleParameterTest.cs: Configuration source updated to work with Mainsoft test suite.
2006-09-12 Leszek Ciesielski <skolima@gmail.com>
* OracleLobTest.cs: New. Regression tests for class
OracleLob.
2006-09-11 Leszek Ciesielski <skolima@gmail.com>
* OracleCommandTest.cs: New. Regression tests for class
OracleCommand.
* OracleParameterTest.cs: New. Regression tests for class
OracleParameter.
2005-09-22 Sebastien Pouliot <sebastien@ximian.com>
* OraclePermissionAttributeTest.cs: Removed *Choice security actions.
2004-09-14 Sebastien Pouliot <sebastien@ximian.com>
* OraclePermissionAttributeTest.cs: New. Unit tests for class
OraclePermissionAttribute.

View File

@@ -0,0 +1,301 @@
//
// OracleCommandTest.cs -
// NUnit Test Cases for OraclePermissionAttribute
//
// Author:
// Leszek Ciesielski <skolima@gmail.com>
//
// Copyright (C) 2006 Forcom (http://www.forcom.com.pl/)
//
// 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 System.Data.SqlClient;
using NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleCommandTest
{
const string COMMAND_TEXT = "SELECT * FROM dual";
OracleCommand command;
IDbCommand interface_command;
[SetUp]
public void SetUp ()
{
command = new OracleCommand ();
interface_command = command;
}
[TearDown]
public void TearDown ()
{
command.Dispose ();
}
[Test] // ctor ()
public void Constructor1 ()
{
OracleCommand cmd = new OracleCommand ();
Assert.AreEqual (string.Empty, cmd.CommandText, "#1");
#if NET_2_0
Assert.AreEqual (0, cmd.CommandTimeout, "#2");
#endif
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#3");
Assert.IsNull (cmd.Connection, "#4");
Assert.IsNull (cmd.Container, "#5");
Assert.IsTrue (cmd.DesignTimeVisible, "#6");
Assert.IsNotNull (cmd.Parameters, "#7");
Assert.AreEqual (0, cmd.Parameters.Count, "#8");
Assert.IsNull (cmd.Site, "#9");
Assert.IsNull (cmd.Transaction, "#10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#11");
}
[Test] // ctor (String)
public void Constructor2 ()
{
OracleCommand cmd = new OracleCommand (COMMAND_TEXT);
Assert.AreEqual (COMMAND_TEXT, cmd.CommandText, "#A1");
#if NET_2_0
Assert.AreEqual (0, cmd.CommandTimeout, "#A2");
#endif
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#A3");
Assert.IsNull (cmd.Connection, "#A4");
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
Assert.IsNotNull (cmd.Parameters, "#A7");
Assert.AreEqual (0, cmd.Parameters.Count, "#A8");
Assert.IsNull (cmd.Site, "#A9");
Assert.IsNull (cmd.Transaction, "#A10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#A11");
cmd = new OracleCommand ((string) null);
Assert.AreEqual (string.Empty, cmd.CommandText, "#B1");
#if NET_2_0
Assert.AreEqual (0, cmd.CommandTimeout, "#B2");
#endif
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#B3");
Assert.IsNull (cmd.Connection, "#B4");
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
Assert.IsNotNull (cmd.Parameters, "#B7");
Assert.AreEqual (0, cmd.Parameters.Count, "#B8");
Assert.IsNull (cmd.Site, "#B9");
Assert.IsNull (cmd.Transaction, "#B10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#B11");
}
[Test] // ctor (String, OracleConnection)
public void Constructor3 ()
{
OracleConnection conn = new OracleConnection ();
OracleCommand cmd;
cmd = new OracleCommand (COMMAND_TEXT, conn);
Assert.AreEqual (COMMAND_TEXT, cmd.CommandText, "#A1");
#if NET_2_0
Assert.AreEqual (0, cmd.CommandTimeout, "#A2");
#endif
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#A3");
Assert.AreSame (conn, cmd.Connection, "#A4");
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
Assert.IsNotNull (cmd.Parameters, "#A7");
Assert.AreEqual (0, cmd.Parameters.Count, "#A8");
Assert.IsNull (cmd.Site, "#A9");
Assert.IsNull (cmd.Transaction, "#A10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#A11");
cmd = new OracleCommand ((string) null, conn);
Assert.AreEqual (string.Empty, cmd.CommandText, "#B1");
#if NET_2_0
Assert.AreEqual (0, cmd.CommandTimeout, "#B2");
#endif
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#B3");
Assert.AreSame (conn, cmd.Connection, "#B4");
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
Assert.IsNotNull (cmd.Parameters, "#B7");
Assert.AreEqual (0, cmd.Parameters.Count, "#B8");
Assert.IsNull (cmd.Site, "#B9");
Assert.IsNull (cmd.Transaction, "#B10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#B11");
cmd = new OracleCommand (COMMAND_TEXT, (OracleConnection) null);
Assert.AreEqual (COMMAND_TEXT, cmd.CommandText, "#C1");
#if NET_2_0
Assert.AreEqual (0, cmd.CommandTimeout, "#C2");
#endif
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#C3");
Assert.IsNull (cmd.Connection, "#C4");
Assert.IsNull (cmd.Container, "#C5");
Assert.IsTrue (cmd.DesignTimeVisible, "#C6");
Assert.IsNotNull (cmd.Parameters, "#C7");
Assert.AreEqual (0, cmd.Parameters.Count, "#C8");
Assert.IsNull (cmd.Site, "#C9");
Assert.IsNull (cmd.Transaction, "#C10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#C11");
}
[Test] // ctor (String, OracleConnection, OracleTransaction)
public void Constructor4 ()
{
OracleConnection conn = new OracleConnection ();
OracleCommand cmd;
cmd = new OracleCommand (COMMAND_TEXT, conn, (OracleTransaction) null);
Assert.AreEqual (COMMAND_TEXT, cmd.CommandText, "#A1");
#if NET_2_0
Assert.AreEqual (0, cmd.CommandTimeout, "#A2");
#endif
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#A3");
Assert.AreSame (conn, cmd.Connection, "#A4");
Assert.IsNull (cmd.Container, "#A5");
Assert.IsTrue (cmd.DesignTimeVisible, "#A6");
Assert.IsNotNull (cmd.Parameters, "#A7");
Assert.AreEqual (0, cmd.Parameters.Count, "#A8");
Assert.IsNull (cmd.Site, "#A9");
Assert.IsNull (cmd.Transaction, "#A10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#A11");
cmd = new OracleCommand ((string) null, conn, (OracleTransaction) null);
Assert.AreEqual (string.Empty, cmd.CommandText, "#B1");
#if NET_2_0
Assert.AreEqual (0, cmd.CommandTimeout, "#B2");
#endif
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#B3");
Assert.AreSame (conn, cmd.Connection, "#B4");
Assert.IsNull (cmd.Container, "#B5");
Assert.IsTrue (cmd.DesignTimeVisible, "#B6");
Assert.IsNotNull (cmd.Parameters, "#B7");
Assert.AreEqual (0, cmd.Parameters.Count, "#B8");
Assert.IsNull (cmd.Site, "#B9");
Assert.IsNull (cmd.Transaction, "#B10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#B11");
cmd = new OracleCommand (COMMAND_TEXT, (OracleConnection) null, (OracleTransaction) null);
Assert.AreEqual (COMMAND_TEXT, cmd.CommandText, "#C1");
#if NET_2_0
Assert.AreEqual (0, cmd.CommandTimeout, "#C2");
#endif
Assert.AreEqual (CommandType.Text, cmd.CommandType, "#C3");
Assert.IsNull (cmd.Connection, "#C4");
Assert.IsNull (cmd.Container, "#C5");
Assert.IsTrue (cmd.DesignTimeVisible, "#C6");
Assert.IsNotNull (cmd.Parameters, "#C7");
Assert.AreEqual (0, cmd.Parameters.Count, "#C8");
Assert.IsNull (cmd.Site, "#C9");
Assert.IsNull (cmd.Transaction, "#C10");
Assert.AreEqual (UpdateRowSource.Both, cmd.UpdatedRowSource, "#C11");
}
[Test] // bug #78765
public void AllowNullTransactionTest ()
{
command.Transaction = null;
interface_command.Transaction = null;
}
[Test]
public void CommandText ()
{
OracleCommand cmd = new OracleCommand ();
cmd.CommandText = COMMAND_TEXT;
Assert.AreSame (COMMAND_TEXT, cmd.CommandText, "#1");
cmd.CommandText = null;
Assert.AreEqual (string.Empty, cmd.CommandText, "#2");
cmd.CommandText = COMMAND_TEXT;
Assert.AreSame (COMMAND_TEXT, cmd.CommandText, "#3");
cmd.CommandText = string.Empty;
Assert.AreEqual (string.Empty, cmd.CommandText, "#4");
}
#if NET_2_0
[Test]
public void CommandTimeout ()
{
Assert.AreEqual (0, command.CommandTimeout, "#1");
command.CommandTimeout = 10;
Assert.AreEqual (0, command.CommandTimeout, "#2");
command.CommandTimeout = int.MaxValue;
Assert.AreEqual (0, command.CommandTimeout, "#3");
command.CommandTimeout = int.MinValue;
Assert.AreEqual (0, command.CommandTimeout, "#4");
}
#endif
[Test]
public void ConnectionTimeout_IDbConnection ()
{
Assert.AreEqual (0, interface_command.CommandTimeout, "#1");
interface_command.CommandTimeout = 10;
Assert.AreEqual (0, interface_command.CommandTimeout, "#2");
interface_command.CommandTimeout = int.MaxValue;
Assert.AreEqual (0, interface_command.CommandTimeout, "#3");
interface_command.CommandTimeout = int.MinValue;
Assert.AreEqual (0, interface_command.CommandTimeout, "#4");
}
[Test]
public void Connection ()
{
OracleConnection connection = new OracleConnection ();
Assert.IsNull (command.Connection, "#1");
command.Connection = connection;
Assert.AreSame (connection, command.Connection, "#2");
Assert.AreSame (connection, interface_command.Connection, "#3");
command.Connection = null;
Assert.IsNull (command.Connection, "#4");
Assert.IsNull (interface_command.Connection, "#5");
}
[Test]
public void Connection_IDbConnection ()
{
OracleConnection connection = new OracleConnection ();
Assert.IsNull (interface_command.Connection, "#A1");
interface_command.Connection = connection;
Assert.AreSame (connection, interface_command.Connection, "#A2");
Assert.AreSame (connection, command.Connection, "#A3");
interface_command.Connection = null;
Assert.IsNull (interface_command.Connection, "#A4");
Assert.IsNull (command.Connection, "#A5");
try {
interface_command.Connection = new SqlConnection ();
Assert.Fail ("#B1");
} catch (InvalidCastException ex) {
Assert.AreEqual (typeof (InvalidCastException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
}
}
}
}

View File

@@ -0,0 +1,89 @@
//
// OracleConnectionTest.cs - NUnit Test Cases for OracleConnection
//
// Author:
// Gert Driesen <drieseng@users.sourceforge.net>
//
// Copyright (C) 2008 Gert Driesen
//
// 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 NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleConnectionTest
{
OracleConnection connection;
[SetUp]
public void SetUp ()
{
connection = new OracleConnection ();
}
[TearDown]
public void TearDown ()
{
connection.Dispose ();
}
[Test]
public void ConnectionString ()
{
connection.ConnectionString = "Data Source=Oracle8i;Integrated Security=yes";
Assert.AreEqual ("Data Source=Oracle8i;Integrated Security=yes",
connection.ConnectionString, "#1");
connection.ConnectionString = null;
Assert.AreEqual (string.Empty, connection.ConnectionString, "#2");
connection.ConnectionString = "Data Source=Oracle8i;Integrated Security=yes";
Assert.AreEqual ("Data Source=Oracle8i;Integrated Security=yes",
connection.ConnectionString, "#3");
connection.ConnectionString = string.Empty;
Assert.AreEqual (string.Empty, connection.ConnectionString, "#3");
}
#if NET_2_0
[Test]
public void ConnectionTimeout ()
{
OracleConnection connection = new OracleConnection ();
Assert.AreEqual (0, connection.ConnectionTimeout, "#1");
connection.ConnectionString = "Data Source=Oracle8i;Integrated Security=yes";
Assert.AreEqual (0, connection.ConnectionTimeout, "#2");
}
#endif
[Test]
public void ConnectionTimeout_IDbConnection ()
{
IDbConnection connection = new OracleConnection ();
Assert.AreEqual (0, connection.ConnectionTimeout, "#1");
connection.ConnectionString = "Data Source=Oracle8i;Integrated Security=yes";
Assert.AreEqual (0, connection.ConnectionTimeout, "#2");
}
}
}

View File

@@ -0,0 +1,154 @@
//
// OracleParameterTest.cs -
// NUnit Test Cases for OracleLob
//
// Author:
// Leszek Ciesielski <skolima@gmail.com>
//
// Copyright (C) 2006 Forcom (http://www.forcom.com.pl/)
//
// 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 NUnit.Framework;
using System.Configuration;
using System.Globalization;
using System.Threading;
using System.Data.OracleClient;
using System.Data;
using System.IO;
using System;
namespace MonoTests.System.Data.OracleClient {
[TestFixture]
public class OracleLobTest {
String connection_string;
OracleConnection connection;
OracleCommand command;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
connection_string = ConfigurationSettings.AppSettings.Get ("ConnectionString");
if(connection_string == null)
Assert.Ignore ("Please consult README.tests.");
}
[SetUp]
public void SetUp ()
{
connection = new OracleConnection (connection_string);
connection.Open ();
using (command = connection.CreateCommand ()) {
// create the tables
command.CommandText =
"create table lob_test (id number(10), lobo blob)";
command.ExecuteNonQuery ();
}
}
[TearDown]
public void TearDown ()
{
using (command = connection.CreateCommand ()) {
command.CommandText = "drop table lob_test";
command.ExecuteNonQuery ();
}
connection.Close ();
connection.Dispose ();
}
[Test] // regression for bug #78898
public void PositionIs0BasedTest ()
{
using (command = connection.CreateCommand ()) { // reusing command from SetUp causes parameter names mismatch
// insert test values
command.CommandText =
"insert into lob_test (id, lobo) values (11, '00000000000000000000000000000')";
command.ExecuteNonQuery ();
// select for writing test values
command.CommandText =
"select lobo from lob_test where id = 11 for update";
using (OracleDataReader reader = command.ExecuteReader ()) {
if (reader.Read ()) {
OracleLob lob = reader.GetOracleLob (0);
Assert.AreEqual (0, lob.Position, "Lob index is not 0 - based.");
lob.Seek (1, SeekOrigin.Current);
Assert.AreEqual (1, lob.Position, "Lob seek placed position wrongly.");
lob.Seek (0, SeekOrigin.End);
Assert.AreEqual (lob.Length , lob.Position, "Lob end is too far away.");
TrySeek (lob, -lob.Length, SeekOrigin.End, 0, 1);
TrySeek (lob, -lob.Length + 5, SeekOrigin.End, 5, 2);
try {
lob.Seek (5, SeekOrigin.End);
Assert.Fail ("Illegal seek succeeded.");
}
catch (ArgumentOutOfRangeException) { // exception is required
}
lob.Seek (lob.Length - 5, SeekOrigin.Begin);
Assert.AreEqual (lob.Length - 5 , lob.Position, "Lob position has unexpected value.");
lob.Seek (0, SeekOrigin.Begin);
TryRead (lob, 10, 1);
lob.Seek (5, SeekOrigin.Begin);
lob.Position = 0;
TryRead (lob, 10, 2);
lob.Position = lob.Length;
TryRead (lob, 0, 3);
lob.Seek (-1, SeekOrigin.Current);
TryRead (lob, 1, 4);
}
else {
Assert.Fail ("Expected records not found.");
}
}
}
}
void TrySeek(OracleLob lob, long offset, SeekOrigin start, long expected, int id)
{
try {
lob.Seek (offset, start);
Assert.AreEqual (expected, lob.Position, "Lob position was unexpected [" + id + ']');
}
catch (ArgumentOutOfRangeException) {
Assert.Fail ("Unable to perform a legal seek [" + id + ']');
}
}
void TryRead(OracleLob lob, long expectedCount, int id)
{
try {
long numberRead = lob.Read (new byte [10], 0, 10);
Assert.AreEqual (expectedCount, numberRead, "Wrong number of bytes read [" + id + ']');
}
catch (OracleException e) {
if (e.Code == 24801)
Assert.Fail ("Unable to perform a legal read [" + id + ']');
else throw;
}
}
}
}

View File

@@ -0,0 +1,177 @@
//
// OraclePermissionAttributeTest.cs -
// NUnit Test Cases for OraclePermissionAttribute
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// 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 NUnit.Framework;
using System;
using System.Data;
using System.Data.OracleClient;
using System.Security;
using System.Security.Permissions;
namespace MonoTests.System.Data.OracleClient {
[TestFixture]
public class OraclePermissionAttributeTest {
[Test]
public void Default ()
{
OraclePermissionAttribute a = new OraclePermissionAttribute (SecurityAction.Assert);
Assert.AreEqual (a.ToString (), a.TypeId.ToString (), "TypeId");
Assert.IsFalse (a.Unrestricted, "Unrestricted");
Assert.IsFalse (a.AllowBlankPassword, "AllowBlankPassword");
#if NET_2_0
Assert.AreEqual (String.Empty, a.ConnectionString, "ConnectionString");
Assert.AreEqual (KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior");
Assert.AreEqual (String.Empty, a.KeyRestrictions, "KeyRestrictions");
Assert.IsFalse (a.ShouldSerializeConnectionString (), "ShouldSerializeConnectionString");
Assert.IsFalse (a.ShouldSerializeKeyRestrictions (), "ShouldSerializeConnectionString");
#endif
OraclePermission ocp = (OraclePermission)a.CreatePermission ();
Assert.IsFalse (ocp.IsUnrestricted (), "IsUnrestricted");
}
[Test]
public void Action ()
{
OraclePermissionAttribute a = new OraclePermissionAttribute (SecurityAction.Assert);
Assert.AreEqual (SecurityAction.Assert, a.Action, "Action=Assert");
a.Action = SecurityAction.Demand;
Assert.AreEqual (SecurityAction.Demand, a.Action, "Action=Demand");
a.Action = SecurityAction.Deny;
Assert.AreEqual (SecurityAction.Deny, a.Action, "Action=Deny");
a.Action = SecurityAction.InheritanceDemand;
Assert.AreEqual (SecurityAction.InheritanceDemand, a.Action, "Action=InheritanceDemand");
a.Action = SecurityAction.LinkDemand;
Assert.AreEqual (SecurityAction.LinkDemand, a.Action, "Action=LinkDemand");
a.Action = SecurityAction.PermitOnly;
Assert.AreEqual (SecurityAction.PermitOnly, a.Action, "Action=PermitOnly");
a.Action = SecurityAction.RequestMinimum;
Assert.AreEqual (SecurityAction.RequestMinimum, a.Action, "Action=RequestMinimum");
a.Action = SecurityAction.RequestOptional;
Assert.AreEqual (SecurityAction.RequestOptional, a.Action, "Action=RequestOptional");
a.Action = SecurityAction.RequestRefuse;
Assert.AreEqual (SecurityAction.RequestRefuse, a.Action, "Action=RequestRefuse");
}
[Test]
public void Action_Invalid ()
{
OraclePermissionAttribute a = new OraclePermissionAttribute ((SecurityAction)Int32.MinValue);
// no validation in attribute
}
[Test]
public void Unrestricted ()
{
OraclePermissionAttribute a = new OraclePermissionAttribute (SecurityAction.Assert);
a.Unrestricted = true;
OraclePermission ocp = (OraclePermission)a.CreatePermission ();
Assert.IsTrue (ocp.IsUnrestricted (), "IsUnrestricted");
Assert.IsFalse (a.AllowBlankPassword, "AllowBlankPassword");
#if NET_2_0
Assert.AreEqual (String.Empty, a.ConnectionString, "ConnectionString");
Assert.AreEqual (KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior");
Assert.AreEqual (String.Empty, a.KeyRestrictions, "KeyRestrictions");
#endif
a.Unrestricted = false;
ocp = (OraclePermission)a.CreatePermission ();
Assert.IsFalse (ocp.IsUnrestricted (), "!IsUnrestricted");
}
[Test]
public void AllowBlankPassword ()
{
OraclePermissionAttribute a = new OraclePermissionAttribute (SecurityAction.Assert);
Assert.IsFalse (a.AllowBlankPassword, "Default");
a.AllowBlankPassword = true;
Assert.IsTrue (a.AllowBlankPassword, "True");
a.AllowBlankPassword = false;
Assert.IsFalse (a.AllowBlankPassword, "False");
}
#if NET_2_0
[Test]
public void ConnectionString ()
{
OraclePermissionAttribute a = new OraclePermissionAttribute (SecurityAction.Assert);
a.ConnectionString = String.Empty;
Assert.AreEqual (String.Empty, a.ConnectionString, "Empty");
a.ConnectionString = "Mono";
Assert.AreEqual ("Mono", a.ConnectionString, "Mono");
a.ConnectionString = null;
Assert.AreEqual (String.Empty, a.ConnectionString, "Empty(null)");
}
[Test]
public void KeyRestrictionBehavior_All ()
{
OraclePermissionAttribute a = new OraclePermissionAttribute (SecurityAction.Assert);
a.KeyRestrictionBehavior = KeyRestrictionBehavior.AllowOnly;
Assert.AreEqual (KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "AllowOnly");
a.KeyRestrictionBehavior = KeyRestrictionBehavior.PreventUsage;
Assert.AreEqual (KeyRestrictionBehavior.PreventUsage, a.KeyRestrictionBehavior, "PreventUsage");
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void KeyRestrictionBehavior_Invalid ()
{
OraclePermissionAttribute a = new OraclePermissionAttribute (SecurityAction.Assert);
a.KeyRestrictionBehavior = (KeyRestrictionBehavior)Int32.MinValue;
}
[Test]
public void KeyRestriction ()
{
OraclePermissionAttribute a = new OraclePermissionAttribute (SecurityAction.Assert);
a.KeyRestrictions = String.Empty;
Assert.AreEqual (String.Empty, a.KeyRestrictions, "Empty");
a.KeyRestrictions = "Mono";
Assert.AreEqual ("Mono", a.KeyRestrictions, "Mono");
a.KeyRestrictions = null;
Assert.AreEqual (String.Empty, a.KeyRestrictions, "Empty(null)");
}
#endif
[Test]
public void Attributes ()
{
Type t = typeof (OraclePermissionAttribute);
Assert.IsTrue (t.IsSerializable, "IsSerializable");
object [] attrs = t.GetCustomAttributes (typeof (AttributeUsageAttribute), false);
Assert.AreEqual (1, attrs.Length, "AttributeUsage");
AttributeUsageAttribute aua = (AttributeUsageAttribute)attrs [0];
Assert.IsTrue (aua.AllowMultiple, "AllowMultiple");
Assert.IsFalse (aua.Inherited, "Inherited");
AttributeTargets at = AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method;
Assert.AreEqual (at, aua.ValidOn, "ValidOn");
}
}
}

View File

@@ -0,0 +1,241 @@
//
// OracleTimeSpanTest.cs - NUnit Test Cases for OracleTimeSpan
//
// Author:
// Gert Driesen <drieseng@users.sourceforge.net>
//
// Copyright (C) 2008 Gert Driesen
//
// 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 NUnit.Framework;
namespace MonoTests.System.Data.OracleClient
{
[TestFixture]
public class OracleTimeSpanTest
{
[SetUp]
public void SetUp ()
{
}
[TearDown]
public void TearDown ()
{
}
[Test] // ctor (Int64)
public void Constructor1 ()
{
OracleTimeSpan ots;
TimeSpan ts;
ts = new TimeSpan (29, 7, 34, 58, 200);
ots = new OracleTimeSpan (ts.Ticks);
Assert.AreEqual (ts.Days, ots.Days, "#A1");
Assert.AreEqual (ts.Hours, ots.Hours, "#A2");
Assert.IsFalse (ots.IsNull, "#A3");
Assert.AreEqual (ts.Milliseconds, ots.Milliseconds, "#A4");
Assert.AreEqual (ts.Minutes, ots.Minutes, "#A5");
Assert.AreEqual (ts.Seconds, ots.Seconds, "#A6");
Assert.AreEqual (ts, ots.Value, "#A7");
Assert.AreEqual (ts.ToString (), ots.ToString (), "#A8");
ts = new TimeSpan (0L);
ots = new OracleTimeSpan (0L);
Assert.AreEqual (ts.Days, ots.Days, "#B1");
Assert.AreEqual (ts.Hours, ots.Hours, "#B2");
Assert.IsFalse (ots.IsNull, "#B3");
Assert.AreEqual (ts.Milliseconds, ots.Milliseconds, "#B4");
Assert.AreEqual (ts.Minutes, ots.Minutes, "#B5");
Assert.AreEqual (ts.Seconds, ots.Seconds, "#B6");
Assert.AreEqual (ts, ots.Value, "#B7");
Assert.AreEqual (ts.ToString (), ots.ToString (), "#B8");
}
[Test] // ctor (OracleTimeSpan)
public void Constructor2 ()
{
TimeSpan ts = new TimeSpan (29, 7, 34, 58, 200);
OracleTimeSpan ots = new OracleTimeSpan (new OracleTimeSpan (ts));
Assert.AreEqual (ts.Days, ots.Days, "#1");
Assert.AreEqual (ts.Hours, ots.Hours, "#2");
Assert.IsFalse (ots.IsNull, "#3");
Assert.AreEqual (ts.Milliseconds, ots.Milliseconds, "#4");
Assert.AreEqual (ts.Minutes, ots.Minutes, "#5");
Assert.AreEqual (ts.Seconds, ots.Seconds, "#6");
Assert.AreEqual (ts, ots.Value, "#7");
Assert.AreEqual (ts.ToString (), ots.ToString (), "#8");
}
[Test] // ctor (OracleTimeSpan)
[ExpectedException (typeof (NullReferenceException))]
public void Constructor2_From_Null ()
{
new OracleTimeSpan (OracleTimeSpan.Null);
}
[Test] // ctor (TimeSpan)
public void Constructor3 ()
{
TimeSpan ts = new TimeSpan (29, 7, 34, 58, 200);
OracleTimeSpan ots = new OracleTimeSpan (ts);
Assert.AreEqual (ts.Days, ots.Days, "#1");
Assert.AreEqual (ts.Hours, ots.Hours, "#2");
Assert.IsFalse (ots.IsNull, "#3");
Assert.AreEqual (ts.Milliseconds, ots.Milliseconds, "#4");
Assert.AreEqual (ts.Minutes, ots.Minutes, "#5");
Assert.AreEqual (ts.Seconds, ots.Seconds, "#6");
Assert.AreEqual (ts, ots.Value, "#7");
Assert.AreEqual (ts.ToString (), ots.ToString (), "#8");
}
[Test]
public void IsNull ()
{
Assert.IsFalse (OracleTimeSpan.MaxValue.IsNull, "#1");
Assert.IsFalse (OracleTimeSpan.MinValue.IsNull, "#2");
Assert.IsTrue (OracleTimeSpan.Null.IsNull, "#3");
}
[Test]
public void MaxValue ()
{
TimeSpan ts = TimeSpan.MaxValue;
OracleTimeSpan ots = OracleTimeSpan.MaxValue;
Assert.AreEqual (ts.Days, ots.Days, "#1");
Assert.AreEqual (ts.Hours, ots.Hours, "#2");
Assert.IsFalse (ots.IsNull, "#3");
Assert.AreEqual (ts.Milliseconds, ots.Milliseconds, "#4");
Assert.AreEqual (ts.Minutes, ots.Minutes, "#5");
Assert.AreEqual (ts.Seconds, ots.Seconds, "#6");
Assert.AreEqual (ts, ots.Value, "#7");
Assert.AreEqual (ts.ToString (), ots.ToString (), "#8");
}
[Test]
public void MinValue ()
{
TimeSpan ts = TimeSpan.MinValue;
OracleTimeSpan ots = OracleTimeSpan.MinValue;
Assert.AreEqual (ts.Days, ots.Days, "#1");
Assert.AreEqual (ts.Hours, ots.Hours, "#2");
Assert.IsFalse (ots.IsNull, "#3");
Assert.AreEqual (ts.Milliseconds, ots.Milliseconds, "#4");
Assert.AreEqual (ts.Minutes, ots.Minutes, "#5");
Assert.AreEqual (ts.Seconds, ots.Seconds, "#6");
Assert.AreEqual (ts, ots.Value, "#7");
Assert.AreEqual (ts.ToString (), ots.ToString (), "#8");
}
[Test]
public void Null ()
{
OracleTimeSpan ots = OracleTimeSpan.Null;
try {
int days = ots.Days;
Assert.Fail ("#A1:" + days);
} catch (InvalidOperationException ex) {
// The value is Null.
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
Assert.IsNull (ex.InnerException, "#A3");
Assert.IsNotNull (ex.Message, "#A4");
Assert.IsTrue (ex.Message.IndexOf ("Null") != -1, "#A5");
}
try {
int hours = ots.Hours;
Assert.Fail ("#B1:" + hours);
} catch (InvalidOperationException ex) {
// The value is Null.
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
Assert.IsTrue (ex.Message.IndexOf ("Null") != -1, "#B5");
}
try {
int milliseconds = ots.Milliseconds;
Assert.Fail ("#C1:" + milliseconds);
} catch (InvalidOperationException ex) {
// The value is Null.
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
Assert.IsNull (ex.InnerException, "#C3");
Assert.IsNotNull (ex.Message, "#C4");
Assert.IsTrue (ex.Message.IndexOf ("Null") != -1, "#C5");
}
try {
int minutes = ots.Minutes;
Assert.Fail ("#D1:" + minutes);
} catch (InvalidOperationException ex) {
// The value is Null.
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
Assert.IsNull (ex.InnerException, "#D3");
Assert.IsNotNull (ex.Message, "#D4");
Assert.IsTrue (ex.Message.IndexOf ("Null") != -1, "#D5");
}
try {
int seconds = ots.Seconds;
Assert.Fail ("#E1:" + seconds);
} catch (InvalidOperationException ex) {
// The value is Null.
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
Assert.IsNull (ex.InnerException, "#E3");
Assert.IsNotNull (ex.Message, "#E4");
Assert.IsTrue (ex.Message.IndexOf ("Null") != -1, "#E5");
}
try {
TimeSpan value = ots.Value;
Assert.Fail ("#F1:" + value);
} catch (InvalidOperationException ex) {
// The value is Null.
Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F2");
Assert.IsNull (ex.InnerException, "#F3");
Assert.IsNotNull (ex.Message, "#F4");
Assert.IsTrue (ex.Message.IndexOf ("Null") != -1, "#F5");
}
}
[Test]
public void ToStringTest ()
{
OracleTimeSpan ots;
ots = OracleTimeSpan.MaxValue;
Assert.AreEqual (TimeSpan.MaxValue.ToString (), ots.ToString (), "#1");
ots = OracleTimeSpan.MinValue;
Assert.AreEqual (TimeSpan.MinValue.ToString (), ots.ToString (), "#2");
ots = OracleTimeSpan.Null;
Assert.AreEqual ("Null", ots.ToString (), "#3");
}
}
}