Files
mono/mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlConnectionStringBuilderTest.cs
T
Sureshkumar T cce8383f1e added a new framework for testing data providers using nunit and mono.data's provider
factory. Moved few stand-alone tests from Test/ to this framework.

In Test:
2005-09-01  Sureshkumar T  <[email protected]>

	* ProviderTests: Added a new framework for testing Data
	Providers. This framework is based on nunit category tests and
	also the provider factory provided by Mono.Data.

In Test/System.Data.SqlClient:
2005-09-01  Sureshkumar T  <[email protected]>

	* SqlDataReaderTest.cs: moved to ProviderTests and integrated with
	connected mode tests
	* SqlCommandTest.cs: -- do --
	* SqlConnectionTest.cs: -- do --
	* SqlTransactionTest.cs: -- do --
	* SqlDataAdapterTest.cs: -- do --

In Test/System.Data.Odbc:
2005-09-01  Sureshkumar T  <[email protected]>

	* OdbcDataAdapterTest.cs: moved to ProviderTests and integrated
	with connected more framework.
	* OdbcCommandTest.cs: -- do --.

	* OdbcParameterCollectionTest.cs: Removed ParameterLengthTrimTest
	to ProviderTests.

In Test/ProviderTests/sql:
2005-09-01  Sureshkumar T  <[email protected]>

	* SCHEMA: schema specification.

	* sqlserver.sql: sql script file to create test schema for mssql
	database. added.

	* mysql.sql: sql script file to create test schema for mysql
	database. added.

In Test/ProviderTests/System.Data.Odbc:
2005-09-01  Sureshkumar T  <[email protected]>

	* OdbcCommandBuilderTest.cs: Added tests for OdbcCommandBuilder.cs
	* OdbcCommandTest.cs: pulled from Test/System.Data.Odbc
	* OdbcDataAdapterTest.cs: pulled from Test/System.Data.Odbc
	* OdbcDataReaderTest.cs: pulled from Test/System.Data.Odbc
	* OdbcParameterCollectionTest.cs: pulled from Test/System.Data.Odbc

In Test/ProviderTests/ProviderIndependant:
2005-09-01  Sureshkumar T  <[email protected]>

	* IDbCommandTest.cs: Added. Provider independent Command tests.

	* DataReaderTest.cs: Added. Provider independent DataReader tests.

In Test/ProviderTests:
2005-09-01  Sureshkumar T  <[email protected]>

	* System.Data.Connected.Tests.dll.sources: source files.

	* app-default.config:
	* app-net_2_0.config:
	configuration files for profiles and lists the assembly
	informations for the Provider factory.

	* odbc.config:
	* sqlserver.config:
	connection string info for respective databases.

	* README: initial.

	pulled connected mode test-cases around Test/* directory into this
	new framework. This framework is based on nunit category based
	test-cases and uses Provider Factories provided in Mono.Data.dll
	to write provider independent code.

In Test/ProviderTests/Common:
2005-09-01  Sureshkumar T  <[email protected]>

	* DBHelper.cs: Added. Class to provide helper methods for other tests.

	* ConnectionManager.cs: Added. Class to manage connections

In Test/ProviderTests/System.Data.SqlClient:
2005-09-01  Sureshkumar T  <[email protected]>

	* SqlCommandBuilderTest.cs: added tests for SqlCommandBuilder
	* SqlCommandTest.cs: pulled from Test/System.Data.SqlClient
	* SqlConnectionStringBuilderTest.cs: pulled from Test/System.Data.SqlClient
	* SqlConnectionTest.cs: pulled from Test/System.Data.SqlClient
	* SqlDataAdapterTest.cs: pulled from Test/System.Data.SqlClient
	* SqlDataReaderTest.cs: pulled from Test/System.Data.SqlClient
	* SqlTransactionTest.cs: pulled from Test/System.Data.SqlClient

	Added attribute Category ("sqlserver") to all these test fixtures.



svn path=/trunk/mcs/; revision=49260
2005-09-01 11:50:04 +00:00

130 lines
4.0 KiB
C#

// SqlConnectionStringBuilderTest.cs - NUnit Test Cases for Testing the
// SqlConnectionStringBuilder class
//
// Author:
// Sureshkumar T ([email protected])
//
//
// 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