0
|
1 using System;
|
|
2 using System.Data;
|
|
3 using System.Data.SqlClient;
|
|
4
|
|
5 using NUnit.Framework;
|
|
6
|
|
7 using BLToolkit.Data;
|
|
8 using BLToolkit.Data.DataProvider;
|
|
9
|
|
10 namespace HowTo.Data
|
|
11 {
|
|
12 [TestFixture]
|
|
13 public class OpenConfig3
|
|
14 {
|
|
15 const string connectionString =
|
|
16 "Server=.;Database=BLToolkitData;Integrated Security=SSPI";
|
|
17
|
|
18 [Test]
|
|
19 public void DbConnectionConfiguration()
|
|
20 {
|
|
21 using (SqlConnection con = new SqlConnection(connectionString))
|
|
22 {
|
|
23 con.Open();
|
|
24
|
|
25 using (DbManager db = /*[a]*/new DbManager(con)/*[/a]*/)
|
|
26 {
|
|
27 Assert.AreEqual(ConnectionState.Open, db.Connection.State);
|
|
28 }
|
|
29 }
|
|
30 }
|
|
31
|
|
32 [Test]
|
|
33 public void DbTransactionConfiguration()
|
|
34 {
|
|
35 using (SqlConnection con = new SqlConnection(connectionString))
|
|
36 {
|
|
37 con.Open();
|
|
38
|
|
39 SqlTransaction tran = con.BeginTransaction();
|
|
40
|
|
41 using (DbManager db = /*[a]*/new DbManager(tran)/*[/a]*/)
|
|
42 {
|
|
43 Assert.AreEqual(ConnectionState.Open, db.Connection.State);
|
|
44 }
|
|
45
|
|
46 tran.Commit();
|
|
47 }
|
|
48 }
|
|
49
|
|
50 [Test]
|
|
51 public void DataProviderConfiguration()
|
|
52 {
|
|
53 SqlDataProvider dp = new SqlDataProvider();
|
|
54
|
|
55 using (DbManager db = /*[a]*/new DbManager(dp, connectionString)/*[/a]*/)
|
|
56 {
|
|
57 Assert.AreEqual(ConnectionState.Open, db.Connection.State);
|
|
58 }
|
|
59 }
|
|
60 }
|
|
61 }
|