comparison HowTo/Data/OpenConfig2.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2 using System.Data;
3
4 using NUnit.Framework;
5
6 using BLToolkit.Data;
7
8 namespace HowTo.Data
9 {
10 [TestFixture]
11 public class OpenConfig2
12 {
13 const string sqlConnectionString =
14 "Server=.;Database=BLToolkitData;Integrated Security=SSPI";
15 const string oleDbConnectionString =
16 "Provider=SQLOLEDB;Data Source=.;Integrated Security=SSPI;Initial Catalog=BLToolkitData";
17
18 [Test]
19 public void Test1()
20 {
21 string defaultConfiguration = DbManager.DefaultConfiguration;
22 DbManager.DefaultConfiguration = ""; //to reset possible previous changes
23
24 try
25 {
26 /*[a]*/DbManager.AddConnectionString/*[/a]*/(
27 sqlConnectionString); // connection string
28
29 using (DbManager db = /*[a]*/new DbManager()/*[/a]*/)
30 {
31 Assert.AreEqual(ConnectionState.Open, db.Connection.State);
32 }
33 }
34 finally
35 {
36 DbManager.DefaultConfiguration = defaultConfiguration; // to restore previous settings
37 }
38
39 }
40
41 [Test]
42 public void Test2()
43 {
44 /*[a]*/DbManager.AddConnectionString/*[/a]*/(
45 "NewConfig", // configuration string
46 sqlConnectionString); // connection string
47
48 using (DbManager db = /*[a]*/new DbManager("NewConfig")/*[/a]*/)
49 {
50 Assert.AreEqual(ConnectionState.Open, db.Connection.State);
51 }
52 }
53
54 [Test]
55 public void Test3()
56 {
57 /*[a]*/DbManager.AddConnectionString/*[/a]*/(
58 "OleDb", // provider name
59 "NewConfig", // configuration string
60 oleDbConnectionString); // connection string
61
62 using (DbManager db = /*[a]*/new DbManager("OleDb", "NewConfig")/*[/a]*/)
63 {
64 Assert.AreEqual(ConnectionState.Open, db.Connection.State);
65 }
66 }
67 }
68 }