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,166 @@
2009-07-29 Veerapuram Varadhan <vvaradhan@novell.com>
* SqlParameterTest.cs: Marked SqlChars/SqlBytes tests for SqlValue
as NotWorking as these types are considered as SqlString/SqlBinary
respectively.
2009-07-26 Gert Driesen <drieseng@users.sourceforge.net>
* SqlParameterTest.cs: Added/improved tests for SqlValue, and
SqlTypes. Improved tests for char and char [] type inferrence.
2009-01-03 Gert Driesen <drieseng@users.sourceforge.net>
* SqlParameterTest.cs: Added .ctor tests. Improved
ParameterType and ResetDbType tests. Added ParameterName,
SourceColumn and Value tests. Partially enable SqlValue
test.
2009-01-03 Gert Driesen <drieseng@users.sourceforge.net>
* SqlCommandBuilderTest.cs: Added tests for CatalogLocation,
CatalogSeparator, ConflictOption, QuoteIdentifier, QuotePrefix,
QuoteSuffix and SchemaSeparator.
* SqlParameterTest.cs: Moved existing tests from ProviderTests
to increase their visibility. Added tests for type inference.
2008-11-09 Gert Driesen <drieseng@users.sourceforge.net>
* SqlConnectionTest.cs: Added test for null check in ClearPool.
2008-08-14 Gert Driesen <drieseng@users.sourceforge.net>
* SqlConnectionTest.cs: Enabled connection string related tests that
previously failed. Added/improved connection string tests.
2008-07-28 Gert Driesen <drieseng@users.sourceforge.net>
* SqlConnectionTest.cs: Enabled tests for ChangePassword argument
checks.
2008-07-28 Gert Driesen <drieseng@users.sourceforge.net>
* SqlCommandTest.cs: Enabled CommandTimeout test. Enabled test for
Prepare with NULL connection. Enabled test for bug #412586.
2008-07-28 Gert Driesen <drieseng@users.sourceforge.net>
* SqlCommandTest.cs: Enabled and improved tests for Execute* with
closed connection.
2008-07-28 Gert Driesen <drieseng@users.sourceforge.net>
* SqlCommandTest.cs: Enabled test for bug #412584.
2008-07-28 Gert Driesen <drieseng@users.sourceforge.net>
* SqlCommandTest.cs: Added tests for bug #412584, #412586, Moved tests
that do not require connection from ProviderTests.
* SqlConnectionTest.cs: Moved tests that do not require connection
from ProviderTests.
2008-07-03 Gert Driesen <drieseng@users.sourceforge.net>
* SqlCommandTest.cs: Removed extra tabs. Update bug number.
2008-04-19 Robert Jordan <robertj@gmx.net>
* SqlCommandTest.cs: Add test case for bug #381100.
2008-03-03 Ankit Jain <jankit@novell.com>
* SqlClientMetaDataCollectionNamesTest.cs: New.
2007-10-21 Gert Driesen <drieseng@users.sourceforge.net>
* SqlCommandTest.cs: Added tests for ctors and CommantText.
* SqlConnectionTest.cs: Added tests for ctors, ConnectionString and
ServerVersion.
* SqlDataAdapterTest.cs: Added tests for ctors, DeleteCommand,
InsertCommand, SelectCommand, UpdateCommand, UpdateBatchSize and
Dispose.
2007-10-18 Gert Driesen <drieseng@users.sourceforge.net>
* SqlConnectionTest.cs: Added tests for BeginTransaction and GetSchema
when connection is closed.
2007-05-29 Gert Driesen <drieseng@users.sourceforge.net>
* SqlCommandTest.cs: Added test for bug #81710.
2005-09-22 Sebastien Pouliot <sebastien@ximian.com>
* SqlClientPermissionAttributeTest.cs: Removed *Choice security
actions.
2005-09-22 Sureshkumar T <tsureshkumar@novell.com>
* SqlConnectionTest.cs (OtherConnectionStringKeywords): marked
Persist security info keyword as not implmented.
2005-09-01 Sureshkumar T <tsureshkumar@novell.com>
* SqlDataReaderTest.cs: moved to ProviderTests and integrated with
connected mode tests
* SqlCommandTest.cs: -- do --
* SqlConnectionTest.cs: -- do --
* SqlTransactionTest.cs: -- do --
* SqlDataAdapterTest.cs: -- do --
2005-06-23 Sureshkumar T <tsureshkumar@novell.com>
* SqlConnectionStringBuilderTest.cs: Added few more tests.
2005-06-21 Sureshkumar T <tsureshkumar@novell.com>
* SqlConnectionStringBuilderTest.cs: Added some preliminary tests.
2005-05-20 Kornél Pál <http://www.kornelpal.hu/>
* SqlDataReaderTest.cs: Corrected and extended bigint test
2005-01-14 Atsushi Enomoto <atsushi@ximian.com>
* SqlClientPermissionTest.cs, SqlClientPermissionAttributeTest.cs:
Fixed some incompatible type of exception between 2.0 and 1.1.
2004-11-01 Gert Driesen <drieseng@users.sourceforge.net>
* SqlCommandTest.cs: Added testcase for bug #66630.
2004-10-30 Umadevi S <sumadevi@novell.com>
* SqlDataAdapterTest.cs - Added testcase for nullguid
2004-10-15 Umadevi S <sumadevi@novell.com>
* SqlDataReaderTest.cs: Added testcase for reading emptyntextfield
2004-10-14 Umadevi S <sumadevi@novell.com>
* SqlCommandTest.cs - added Test for clone method
2004-09-24 Umadevi S <sumadevi@novell.com>
* SqlTransactionTest.cs -new file .unit testing for SqlTransaction
2004-09-15 Sebastien Pouliot <sebastien@ximian.com>
* SqlClientPermissionTest.cs: New. Unit tests for SqlClientPermission.
2004-09-13 Sebastien Pouliot <sebastien@ximian.com>
* SqlClientPermissionAttributeTest.cs: New. Unit tests for SqlClient
PermissionAttribute.
2004-09-02 Umadevi S <sumadevi@novell.com>
* SqlCommandTest.cs - added file. Testing ExecuteNonQuery
2004-09-02 Umadevi S <sumadevi@novell.com>
* SqlDataReaderTest.cs - added file
2004-08-20 Umadevi S <sumadevi@novell.com>
* Added testcase in SqlDataAdapter.cs for Fillschema
2004-08-19 Gert Driesen <drieseng@users.souceforge.net>
* SqlConnectionTest.cs: Added testcases for bug #63165.
2004-08-19 Umadevi S <sumadevi@novell.com>
* Added file SqlDataAdapterTest.cs - to test update method on a
datatable

View File

@@ -0,0 +1,103 @@
//
// SqlBulkCopyTest.cs - NUnit Test Cases for testing the
// SqlBulkCopy class
// Author:
// Oleg Petrov (ch5oh@qip.ru)
//
// Copyright (c) 2004 Novell Inc., and the individuals listed
// on the ChangeLog entries.
//
// 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.SqlClient;
using NUnit.Framework;
namespace MonoTests.System.Data.SqlClient {
[TestFixture]
public class SqlBulkCopyTest {
private const string testFailParamNameMessage = "We have to provide the same parameter name as in original .NET";
[Test] // .ctor(SqlConnection connection)
[ExpectedException (typeof(ArgumentNullException))]
public void ConstructorNotNull1 ()
{
new SqlBulkCopy ((SqlConnection)null);
}
[Test] // .ctor(string connectionString)
[ExpectedException (typeof(ArgumentNullException))]
public void ConstructorNotNull2 ()
{
new SqlBulkCopy ((string)null);
}
[Test] // .ctor(SqlConnection connection)
[ExpectedException (typeof(ArgumentNullException))]
public void ConstructorNotNull3 ()
{
try {
new SqlBulkCopy ((SqlConnection)null);
} catch (ArgumentNullException ane) {
Assert.AreEqual ("connection", ane.ParamName, "#001 - " + testFailParamNameMessage);
throw;
}
}
[Test] // .ctor(string connectionString)
[ExpectedException (typeof(ArgumentNullException))]
public void ConstructorNotNull4 ()
{
try {
new SqlBulkCopy ((string)null);
} catch (ArgumentNullException ane) {
Assert.AreEqual ("connectionString", ane.ParamName, "#002 - " + testFailParamNameMessage);
throw;
}
}
[Test] // .ctor(string connectionString)
[ExpectedException (typeof(ArgumentNullException))]
public void ConstructorNotNull5 ()
{
try {
new SqlBulkCopy ((string)null, SqlBulkCopyOptions.Default);
} catch (ArgumentNullException ane) {
Assert.AreEqual ("connectionString", ane.ParamName, "#003 - " + testFailParamNameMessage);
throw;
}
}
[Test] // .ctor(string connectionString)
[ExpectedException (typeof(ArgumentNullException))]
public void ConstructorNotNull6 ()
{
try {
new SqlBulkCopy ((SqlConnection)null, SqlBulkCopyOptions.Default, null);
} catch (ArgumentNullException ane) {
Assert.AreEqual ("connection", ane.ParamName, "#004 - " + testFailParamNameMessage);
throw;
}
}
}
}

View File

@@ -0,0 +1,57 @@
//
// SqlClientMetaDataCollectionNamesTest.cs - NUnit Test Cases for testing the
// SqlClientMetaDataCollectionNames class
// Author:
// Ankit Jain <jankit@novell.com>
//
// Copyright (C) 2008 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 System.Data.SqlClient;
using NUnit.Framework;
#if NET_2_0
namespace MonoTests.System.Data.SqlClient
{
[TestFixture]
public class SqlClientMetaDataCollectionNamesTest
{
[Test]
public void ValuesTest ()
{
Assert.AreEqual (SqlClientMetaDataCollectionNames.Columns, "Columns");
Assert.AreEqual (SqlClientMetaDataCollectionNames.Databases, "Databases");
Assert.AreEqual (SqlClientMetaDataCollectionNames.ForeignKeys, "ForeignKeys");
Assert.AreEqual (SqlClientMetaDataCollectionNames.IndexColumns, "IndexColumns");
Assert.AreEqual (SqlClientMetaDataCollectionNames.Indexes, "Indexes");
Assert.AreEqual (SqlClientMetaDataCollectionNames.Parameters, "Parameters");
Assert.AreEqual (SqlClientMetaDataCollectionNames.ProcedureColumns, "ProcedureColumns");
Assert.AreEqual (SqlClientMetaDataCollectionNames.Procedures, "Procedures");
Assert.AreEqual (SqlClientMetaDataCollectionNames.Tables, "Tables");
Assert.AreEqual (SqlClientMetaDataCollectionNames.UserDefinedTypes, "UserDefinedTypes");
Assert.AreEqual (SqlClientMetaDataCollectionNames.Users, "Users");
Assert.AreEqual (SqlClientMetaDataCollectionNames.ViewColumns, "ViewColumns");
Assert.AreEqual (SqlClientMetaDataCollectionNames.Views, "Views");
}
}
}
#endif

View File

@@ -0,0 +1,182 @@
//
// SqlClientPermissionAttributeTest.cs -
// NUnit Test Cases for SqlClientPermissionAttribute
//
// 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.SqlClient;
using System.Security;
using System.Security.Permissions;
namespace MonoTests.System.Data.SqlClient {
[TestFixture]
#if MOBILE
[Ignore ("CAS is not supported and parts will be linked away")]
#endif
public class SqlClientPermissionAttributeTest {
[Test]
public void Default ()
{
SqlClientPermissionAttribute a = new SqlClientPermissionAttribute (SecurityAction.Assert);
Assert.AreEqual (a.ToString (), a.TypeId.ToString (), "TypeId");
Assert.IsFalse (a.Unrestricted, "Unrestricted");
Assert.IsFalse (a.AllowBlankPassword, "AllowBlankPassword");
Assert.AreEqual (String.Empty, a.ConnectionString, "ConnectionString");
Assert.AreEqual (KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior");
Assert.AreEqual (String.Empty, a.KeyRestrictions, "KeyRestrictions");
#if NET_2_0
Assert.IsFalse (a.ShouldSerializeConnectionString (), "ShouldSerializeConnectionString");
Assert.IsFalse (a.ShouldSerializeKeyRestrictions (), "ShouldSerializeConnectionString");
#endif
SqlClientPermission sp = (SqlClientPermission)a.CreatePermission ();
Assert.IsFalse (sp.IsUnrestricted (), "IsUnrestricted");
}
[Test]
public void Action ()
{
SqlClientPermissionAttribute a = new SqlClientPermissionAttribute (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 ()
{
SqlClientPermissionAttribute a = new SqlClientPermissionAttribute ((SecurityAction)Int32.MinValue);
// no validation in attribute
}
[Test]
public void Unrestricted ()
{
SqlClientPermissionAttribute a = new SqlClientPermissionAttribute (SecurityAction.Assert);
a.Unrestricted = true;
SqlClientPermission scp = (SqlClientPermission)a.CreatePermission ();
Assert.IsTrue (scp.IsUnrestricted (), "IsUnrestricted");
Assert.IsFalse (a.AllowBlankPassword, "AllowBlankPassword");
Assert.AreEqual (String.Empty, a.ConnectionString, "ConnectionString");
Assert.AreEqual (KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior");
Assert.AreEqual (String.Empty, a.KeyRestrictions, "KeyRestrictions");
a.Unrestricted = false;
scp = (SqlClientPermission)a.CreatePermission ();
Assert.IsFalse (scp.IsUnrestricted (), "!IsUnrestricted");
}
[Test]
public void AllowBlankPassword ()
{
SqlClientPermissionAttribute a = new SqlClientPermissionAttribute (SecurityAction.Assert);
Assert.IsFalse (a.AllowBlankPassword, "Default");
a.AllowBlankPassword = true;
Assert.IsTrue (a.AllowBlankPassword, "True");
a.AllowBlankPassword = false;
Assert.IsFalse (a.AllowBlankPassword, "False");
}
[Test]
public void ConnectionString ()
{
SqlClientPermissionAttribute a = new SqlClientPermissionAttribute (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 ()
{
SqlClientPermissionAttribute a = new SqlClientPermissionAttribute (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]
#if NET_2_0
[ExpectedException (typeof (ArgumentOutOfRangeException))]
#else
[ExpectedException (typeof (ArgumentException))]
#endif
public void KeyRestrictionBehavior_Invalid ()
{
SqlClientPermissionAttribute a = new SqlClientPermissionAttribute (SecurityAction.Assert);
a.KeyRestrictionBehavior = (KeyRestrictionBehavior)Int32.MinValue;
}
[Test]
public void KeyRestriction ()
{
SqlClientPermissionAttribute a = new SqlClientPermissionAttribute (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)");
}
[Test]
public void Attributes ()
{
Type t = typeof (SqlClientPermissionAttribute);
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,125 @@
//
// SqlClientPermissionTest.cs - NUnit Test Cases for SqlClientPermission
//
// 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.Common;
using System.Data.SqlClient;
using System.Security;
using System.Security.Permissions;
namespace MonoTests.System.Data.SqlClient {
// NOTE: Most tests are are located in the base class, DBDataPermission
[TestFixture]
#if MOBILE
[Ignore ("CAS is not supported and parts will be linked away")]
#endif
public class SqlClientPermissionTest {
private void Check (string msg, DBDataPermission dbdp, bool blank, bool unrestricted, int count)
{
Assert.AreEqual (blank, dbdp.AllowBlankPassword, msg + ".AllowBlankPassword");
Assert.AreEqual (unrestricted, dbdp.IsUnrestricted (), msg + ".IsUnrestricted");
if (count == 0)
Assert.IsNull (dbdp.ToXml ().Children, msg + ".Count != 0");
else
Assert.AreEqual (count, dbdp.ToXml ().Children.Count, msg + ".Count");
}
[Test]
#if NET_2_0
[ExpectedException (typeof (ArgumentOutOfRangeException))]
#else
[ExpectedException (typeof (ArgumentException))]
#endif
public void PermissionState_Invalid ()
{
PermissionState ps = (PermissionState)Int32.MinValue;
SqlClientPermission perm = new SqlClientPermission (ps);
}
[Test]
public void None ()
{
SqlClientPermission perm = new SqlClientPermission (PermissionState.None);
Check ("None-1", perm, false, false, 0);
perm.AllowBlankPassword = true;
Check ("None-2", perm, true, false, 0);
SqlClientPermission copy = (SqlClientPermission)perm.Copy ();
Check ("Copy_None-1", copy, true, false, 0);
copy.AllowBlankPassword = false;
Check ("Copy_None-2", copy, false, false, 0);
}
[Test]
public void None_Childs ()
{
SqlClientPermission perm = new SqlClientPermission (PermissionState.None);
perm.Add ("data source=localhost;", String.Empty, KeyRestrictionBehavior.AllowOnly);
perm.Add ("data source=127.0.0.1;", "password=;", KeyRestrictionBehavior.PreventUsage);
Check ("None-Childs-1", perm, false, false, 2);
perm.AllowBlankPassword = true;
Check ("None-Childs-2", perm, true, false, 2);
SqlClientPermission copy = (SqlClientPermission)perm.Copy ();
Check ("Copy_None-Childs-1", copy, true, false, 2);
copy.AllowBlankPassword = false;
Check ("Copy_None-Childs-2", copy, false, false, 2);
}
[Test]
public void Unrestricted ()
{
SqlClientPermission perm = new SqlClientPermission (PermissionState.Unrestricted);
Check ("Unrestricted-1", perm, false, true, 0);
perm.AllowBlankPassword = true;
Check ("Unrestricted-2", perm, true, true, 0);
SqlClientPermission copy = (SqlClientPermission)perm.Copy ();
// note: Unrestricted is always created with default values (so AllowBlankPassword is false)
Check ("Copy_Unrestricted-1", copy, false, true, 0);
copy.AllowBlankPassword = true;
Check ("Copy_Unrestricted-2", copy, true, true, 0);
}
[Test]
public void Unrestricted_Add ()
{
SqlClientPermission perm = new SqlClientPermission (PermissionState.Unrestricted);
Check ("Unrestricted-NoChild", perm, false, true, 0);
perm.Add ("data source=localhost;", String.Empty, KeyRestrictionBehavior.AllowOnly);
// note: Lost unrestricted state when children was added
Check ("Unrestricted-WithChild", perm, false, false, 1);
}
}
}

View File

@@ -0,0 +1,404 @@
// SqlCommandBuilderTest.cs - NUnit Test Cases for testing SqlCommandBuilder.
//
// Authors:
// 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;
#if NET_2_0
using System.Data;
using System.Data.Common;
#endif
using System.Data.SqlClient;
using NUnit.Framework;
namespace MonoTests.System.Data.Odbc
{
[TestFixture]
public class SqlCommandBuilderTest
{
#if NET_2_0
[Test]
public void CatalogLocationTest ()
{
SqlCommandBuilder cb = new SqlCommandBuilder ();
Assert.AreEqual (CatalogLocation.Start, cb.CatalogLocation, "#1");
cb.CatalogLocation = CatalogLocation.Start;
Assert.AreEqual (CatalogLocation.Start, cb.CatalogLocation, "#2");
}
[Test]
public void CatalogLocation_Value_Invalid ()
{
SqlCommandBuilder cb = new SqlCommandBuilder ();
try {
cb.CatalogLocation = (CatalogLocation) 666;
Assert.Fail ("#A1");
} catch (ArgumentException ex) {
// The only acceptable value for the property
// 'CatalogLocation' is 'Start'
Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
Assert.IsNull (ex.InnerException, "#A3");
Assert.IsNotNull (ex.Message, "#A4");
Assert.IsTrue (ex.Message.IndexOf ("'CatalogLocation'") != -1, "#A5:" + ex.Message);
Assert.IsTrue (ex.Message.IndexOf ("'Start'") != -1, "#A6:" + ex.Message);
Assert.IsNull (ex.ParamName, "#A7");
}
Assert.AreEqual (CatalogLocation.Start, cb.CatalogLocation, "#A7");
try {
cb.CatalogLocation = CatalogLocation.End;
Assert.Fail ("#B1");
} catch (ArgumentException ex) {
// The only acceptable value for the property
// 'CatalogLocation' is 'Start'
Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
Assert.IsTrue (ex.Message.IndexOf ("'CatalogLocation'") != -1, "#B5:" + ex.Message);
Assert.IsTrue (ex.Message.IndexOf ("'Start'") != -1, "#B6:" + ex.Message);
Assert.IsNull (ex.ParamName, "#B7");
}
Assert.AreEqual (CatalogLocation.Start, cb.CatalogLocation, "#B8");
}
[Test]
public void CatalogSeparator ()
{
SqlCommandBuilder cb = new SqlCommandBuilder ();
Assert.AreEqual (".", cb.CatalogSeparator, "#1");
}
[Test]
public void CatalogSeparator_Value_Invalid ()
{
string [] separators = new string [] {
"x",
"'",
"[x",
string.Empty,
null
};
SqlCommandBuilder cb = new SqlCommandBuilder ();
for (int i = 0; i < separators.Length; i++) {
try {
cb.CatalogSeparator = separators [i];
Assert.Fail ("#1:" + i);
} catch (ArgumentException ex) {
// The acceptable value for the property
// 'CatalogSeparator' is '.'
Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + i);
Assert.IsNull (ex.InnerException, "#3:" + i);
Assert.IsNotNull (ex.Message, "#4:" + i);
Assert.IsTrue (ex.Message.IndexOf ("'CatalogSeparator'") != -1, "#5:" + ex.Message);
Assert.IsTrue (ex.Message.IndexOf ("'.'") != -1, "#6:" + ex.Message);
Assert.IsNull (ex.ParamName, "#7:" + i);
}
}
}
[Test]
public void ConflictOptionTest ()
{
SqlCommandBuilder cb = new SqlCommandBuilder ();
Assert.AreEqual (ConflictOption.CompareAllSearchableValues, cb.ConflictOption, "#1");
cb.ConflictOption = ConflictOption.CompareRowVersion;
Assert.AreEqual (ConflictOption.CompareRowVersion, cb.ConflictOption, "#2");
}
[Test]
public void ConflictOption_Value_Invalid ()
{
SqlCommandBuilder cb = new SqlCommandBuilder ();
cb.ConflictOption = ConflictOption.CompareRowVersion;
try {
cb.ConflictOption = (ConflictOption) 666;
Assert.Fail ("#1");
} catch (ArgumentOutOfRangeException ex) {
// The ConflictOption enumeration value, 666, is invalid
Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf ("ConflictOption") != -1, "#5:" + ex.Message);
Assert.IsTrue (ex.Message.IndexOf ("666") != -1, "#6:" + ex.Message);
Assert.AreEqual ("ConflictOption", ex.ParamName, "#7");
}
Assert.AreEqual (ConflictOption.CompareRowVersion, cb.ConflictOption, "#8");
}
[Test] // QuoteIdentifier (String)
public void QuoteIdentifier ()
{
SqlCommandBuilder cb;
cb = new SqlCommandBuilder ();
Assert.AreEqual ("[mono]", cb.QuoteIdentifier ("mono"), "#A1");
Assert.AreEqual ("[]", cb.QuoteIdentifier (string.Empty), "#A2");
Assert.AreEqual ("[Z]", cb.QuoteIdentifier ("Z"), "#A3");
Assert.AreEqual ("[[]", cb.QuoteIdentifier ("["), "#A4");
Assert.AreEqual ("[A[C]", cb.QuoteIdentifier ("A[C"), "#A5");
Assert.AreEqual ("[]]]", cb.QuoteIdentifier ("]"), "#A6");
Assert.AreEqual ("[A]]C]", cb.QuoteIdentifier ("A]C"), "#A7");
Assert.AreEqual ("[[]]]", cb.QuoteIdentifier ("[]"), "#A8");
Assert.AreEqual ("[A[]]C]", cb.QuoteIdentifier ("A[]C"), "#A9");
cb = new SqlCommandBuilder ();
cb.QuotePrefix = "\"";
cb.QuoteSuffix = "\"";
Assert.AreEqual ("\"mono\"", cb.QuoteIdentifier ("mono"), "#B1");
Assert.AreEqual ("\"\"", cb.QuoteIdentifier (string.Empty), "#B2");
Assert.AreEqual ("\"Z\"", cb.QuoteIdentifier ("Z"), "#B3");
Assert.AreEqual ("\"\"\"\"", cb.QuoteIdentifier ("\""), "#B4");
Assert.AreEqual ("\"A\"\"C\"", cb.QuoteIdentifier ("A\"C"), "#B5");
}
[Test]
public void QuoteIdentifier_PrefixSuffix_NoMatch ()
{
SqlCommandBuilder cb;
cb = new SqlCommandBuilder ();
cb.QuoteSuffix = "\"";
try {
cb.QuoteIdentifier ("mono");
Assert.Fail ("#A1");
} catch (ArgumentException ex) {
// Specified QuotePrefix and QuoteSuffix values
// do not match
Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");
Assert.IsNull (ex.InnerException, "#A3");
Assert.IsNotNull (ex.Message, "#A4");
Assert.IsTrue (ex.Message.IndexOf ("QuotePrefix") != -1, "#A5:" + ex.Message);
Assert.IsTrue (ex.Message.IndexOf ("QuoteSuffix") != -1, "#A6:" + ex.Message);
Assert.IsNull (ex.ParamName, "#A7");
}
cb = new SqlCommandBuilder ();
cb.QuotePrefix = "\"";
try {
cb.QuoteIdentifier ("mono");
Assert.Fail ("#B1");
} catch (ArgumentException ex) {
// Specified QuotePrefix and QuoteSuffix values
// do not match
Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
Assert.IsTrue (ex.Message.IndexOf ("QuotePrefix") != -1, "#B5:" + ex.Message);
Assert.IsTrue (ex.Message.IndexOf ("QuoteSuffix") != -1, "#B6:" + ex.Message);
Assert.IsNull (ex.ParamName, "#B7");
}
}
[Test] // QuoteIdentifier (String)
public void QuoteIdentifier_UnquotedIdentifier_Null ()
{
SqlCommandBuilder cb = new SqlCommandBuilder ();
try {
cb.QuoteIdentifier ((string) null);
Assert.Fail ("#1");
} catch (ArgumentNullException ex) {
Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.AreEqual ("unquotedIdentifier", ex.ParamName, "#5");
}
}
#endif
[Test]
public void QuotePrefix ()
{
SqlCommandBuilder cb = new SqlCommandBuilder ();
#if NET_2_0
Assert.AreEqual ("[", cb.QuotePrefix, "#A1");
Assert.AreEqual ("]", cb.QuoteSuffix, "#A2");
cb.QuotePrefix = "\"";
Assert.AreEqual ("\"", cb.QuotePrefix, "#B1");
Assert.AreEqual ("]", cb.QuoteSuffix, "#B2");
cb.QuotePrefix = "[";
Assert.AreEqual ("[", cb.QuotePrefix, "#C1");
Assert.AreEqual ("]", cb.QuoteSuffix, "#C2");
#else
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#A1");
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#A2");
cb.QuotePrefix = "\"";
Assert.AreEqual ("\"", cb.QuotePrefix, "#B1");
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#B2");
cb.QuotePrefix = string.Empty;
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#C1");
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#C2");
cb.QuotePrefix = "x";
Assert.AreEqual ("x", cb.QuotePrefix, "#D1");
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#D2");
cb.QuotePrefix = null;
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#E1");
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#E2");
cb.QuotePrefix = "mono";
Assert.AreEqual ("mono", cb.QuotePrefix, "#F1");
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#F2");
cb.QuotePrefix = " ";
Assert.AreEqual (" ", cb.QuotePrefix, "#G1");
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#G2");
#endif
}
#if NET_2_0
[Test]
public void QuotePrefix_Value_Invalid ()
{
string [] prefixes = new string [] {
"x",
"'",
"[x",
string.Empty,
null,
"]"
};
SqlCommandBuilder cb = new SqlCommandBuilder ();
for (int i = 0; i < prefixes.Length; i++) {
try {
cb.QuotePrefix = prefixes [i];
Assert.Fail ("#1:" + i);
} catch (ArgumentException ex) {
// The acceptable values for the property
// 'QuoteSuffix' are ']' or '"'
Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + i);
Assert.IsNull (ex.InnerException, "#3:" + i);
Assert.IsNotNull (ex.Message, "#4:" + i);
Assert.IsNull (ex.ParamName, "#5:" + i);
}
}
}
#endif
[Test]
public void QuoteSuffix ()
{
SqlCommandBuilder cb = new SqlCommandBuilder ();
#if NET_2_0
Assert.AreEqual ("[", cb.QuotePrefix, "#A1");
Assert.AreEqual ("]", cb.QuoteSuffix, "#A2");
cb.QuoteSuffix = "\"";
Assert.AreEqual ("[", cb.QuotePrefix, "#B1");
Assert.AreEqual ("\"", cb.QuoteSuffix, "#B2");
cb.QuoteSuffix = "]";
Assert.AreEqual ("[", cb.QuotePrefix, "#C1");
Assert.AreEqual ("]", cb.QuoteSuffix, "#C2");
#else
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#A1");
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#A2");
cb.QuoteSuffix = "\"";
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#B1");
Assert.AreEqual ("\"", cb.QuoteSuffix, "#B2");
cb.QuoteSuffix = string.Empty;
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#C1");
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#C2");
cb.QuoteSuffix = "x";
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#D1");
Assert.AreEqual ("x", cb.QuoteSuffix, "#D2");
cb.QuoteSuffix = null;
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#E1");
Assert.AreEqual (string.Empty, cb.QuoteSuffix, "#E2");
cb.QuoteSuffix = "mono";
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#F1");
Assert.AreEqual ("mono", cb.QuoteSuffix, "#F2");
cb.QuoteSuffix = " ";
Assert.AreEqual (string.Empty, cb.QuotePrefix, "#G1");
Assert.AreEqual (" ", cb.QuoteSuffix, "#G2");
#endif
}
#if NET_2_0
[Test]
public void QuoteSuffix_Value_Invalid ()
{
string [] suffixes = new string [] {
"x",
"'",
"[x",
string.Empty,
null,
"["
};
SqlCommandBuilder cb = new SqlCommandBuilder ();
for (int i = 0; i < suffixes.Length; i++) {
try {
cb.QuoteSuffix = suffixes [i];
Assert.Fail ("#1:" + i);
} catch (ArgumentException ex) {
// The acceptable values for the property
// 'QuoteSuffix' are ']' or '"'
Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + i);
Assert.IsNull (ex.InnerException, "#3:" + i);
Assert.IsNotNull (ex.Message, "#4:" + i);
Assert.IsNull (ex.ParamName, "#5:" + i);
}
}
}
[Test]
public void SchemaSeparator ()
{
SqlCommandBuilder cb = new SqlCommandBuilder ();
Assert.AreEqual (".", cb.SchemaSeparator, "#1");
cb.SchemaSeparator = ".";
Assert.AreEqual (".", cb.SchemaSeparator, "#2");
}
[Test]
public void SchemaSeparator_Value_Invalid ()
{
string [] separators = new string [] {
"x",
"'",
"[x",
string.Empty,
null
};
SqlCommandBuilder cb = new SqlCommandBuilder ();
for (int i = 0; i < separators.Length; i++) {
try {
cb.SchemaSeparator = separators [i];
Assert.Fail ("#1:" + i);
} catch (ArgumentException ex) {
// The acceptable value for the property
// 'SchemaSeparator' is '.'
Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2:" + i);
Assert.IsNull (ex.InnerException, "#3:" + i);
Assert.IsNotNull (ex.Message, "#4:" + i);
Assert.IsTrue (ex.Message.IndexOf ("'SchemaSeparator'") != -1, "#5:" + ex.Message);
Assert.IsTrue (ex.Message.IndexOf ("'.'") != -1, "#6:" + ex.Message);
Assert.IsNull (ex.ParamName, "#7:" + i);
}
}
}
#endif
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,129 @@
// SqlConnectionStringBuilderTest.cs - NUnit Test Cases for Testing the
// SqlConnectionStringBuilder class
//
// Author:
// Sureshkumar T (tsureshkumar@novell.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.
//
#if NET_2_0
#region Using directives
using System;
using System.Text;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using NUnit.Framework;
#endregion
namespace MonoTests.System.Data.Common
{
[TestFixture]
public class SqlConnectionStringBuilderTest
{
private SqlConnectionStringBuilder builder = null;
[Test]
public void DefaultValuestTest ()
{
builder = new SqlConnectionStringBuilder ();
Assert.AreEqual ("", builder.ConnectionString, "#DV1 default values is wrong");
}
[Test]
public void DefaultValuestTest2 ()
{
builder = new SqlConnectionStringBuilder ("SERVER=localhost;");
Assert.AreEqual ("Data Source=localhost", builder.ConnectionString, "#DVT1 default values is wrong");
}
[Test]
public void PropertiesTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER=localhost;");
builder.AsynchronousProcessing = true;
builder.ApplicationName = "mono test";
Assert.AreEqual (true,
builder.ConnectionString.Contains ("Asynchronous Processing=True"),
"#PT1 boolean value must be true");
}
[Test]
public void ItemTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER=localhost;");
builder ["Network Library"] = "DBMSSOCN";
Assert.AreEqual (true,
builder.ConnectionString.Contains ("Network Library=dbmssocn"),
"#PT1 network library should exist");
}
public void NullTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER=localhost;Network=DBMSSOCN");
builder ["Network Library"] = null;
Assert.AreEqual ("Data Source=localhost", builder.ConnectionString,
"#NT1 should remove the key if set with null");
}
public void ContainsKeyTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER=localhost;Network=DBMSSOCN");
Assert.AreEqual (true, builder.ContainsKey ("NETWORK"),
"#CKT1 should say true");
Assert.AreEqual (false, builder.ContainsKey ("ABCD"),
"#CKT2 should say false");
}
[Test, ExpectedException (typeof (ArgumentException))]
public void InvalidKeyTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER=localhost;Network=DBMSSOCN");
int value = (int) builder ["ABCD"];
value++; // to avoid warning
}
[Test]
public void RemoveTest ()
{
builder = new SqlConnectionStringBuilder ("SERVER = localhost ;Network=DBMSSOCN");
// non existing key
Assert.AreEqual (false, builder.Remove ("ABCD"),
"#RT1 cannot remove non existant key");
Assert.AreEqual (true, builder.Remove ("NETWORK library"),
"#RT2 should remove the key");
Assert.AreEqual ("Data Source=localhost", builder.ConnectionString,
"#RT3 should have removed the key");
}
}
}
#endif // NET_2_0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff