using System;
using System.Data;
using System.Data.SqlClient;
using NUnit.Framework;
using BLToolkit.Data;
using BLToolkit.Data.DataProvider;
namespace HowTo.Data
{
[TestFixture]
public class OpenConfig3
{
const string connectionString =
"Server=.;Database=BLToolkitData;Integrated Security=SSPI";
[Test]
public void DbConnectionConfiguration()
{
using (SqlConnection con = new SqlConnection(connectionString))
{
con.Open();
using (DbManager db = new DbManager(con))
{
Assert.AreEqual(ConnectionState.Open, db.Connection.State);
}
}
}
[Test]
public void DbTransactionConfiguration()
{
using (SqlConnection con = new SqlConnection(connectionString))
{
con.Open();
SqlTransaction tran = con.BeginTransaction();
using (DbManager db = new DbManager(tran))
{
Assert.AreEqual(ConnectionState.Open, db.Connection.State);
}
tran.Commit();
}
}
[Test]
public void DataProviderConfiguration()
{
SqlDataProvider dp = new SqlDataProvider();
using (DbManager db = new DbManager(dp, connectionString))
{
Assert.AreEqual(ConnectionState.Open, db.Connection.State);
}
}
}
} |