**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Data / Test / System.Data.SqlClient / SqlConnectionTest.cs
blobbc8fdff89ae28fad3e179b983a6ef9d37f00b8a5
1 //
2 // SqlConnectionTest.cs - NUnit Test Cases for testing the
3 // SqlConnection class
4 // Author:
5 // Gert Driesen (drieseng@users.sourceforge.net)
6 //
7 // Copyright (c) 2004 Novell Inc., and the individuals listed
8 // on the ChangeLog entries.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System;
31 using System.Data;
32 using System.Data.SqlClient;
34 using NUnit.Framework;
36 namespace MonoTests.System.Data.SqlClient
38 [TestFixture]
39 public class SqlConnectionTest
41 [Test]
42 public void DefaultConnectionValues()
44 SqlConnection cn = new SqlConnection ();
46 Assert.AreEqual (15, cn.ConnectionTimeout,
47 "Default connection timeout should be 15 seconds");
48 Assert.AreEqual ("", cn.Database,
49 "Default database name should be empty string");
50 Assert.AreEqual ("", cn.DataSource,
51 "Default data source should be empty string");
52 Assert.AreEqual (8192, cn.PacketSize,
53 "Default packet size should be 8192 bytes");
54 Assert.AreEqual (ConnectionState.Closed, cn.State,
55 "Default connection state should be closed");
58 [Test]
59 public void ConnectionTimeoutSynonyms()
61 SqlConnection cn = null;
63 cn = new SqlConnection ();
64 cn.ConnectionString = "Connection Timeout=25";
65 Assert.AreEqual (25, cn.ConnectionTimeout);
67 cn = new SqlConnection ();
68 cn.ConnectionString = "Connect Timeout=25";
69 Assert.AreEqual (25, cn.ConnectionTimeout);
71 cn = new SqlConnection ();
72 cn.ConnectionString = "Timeout=25";
73 Assert.AreEqual (25, cn.ConnectionTimeout);
76 [Test]
77 public void NetworkLibrarySynonyms()
79 SqlConnection cn = new SqlConnection ();
80 cn.ConnectionString = "Net=DBMSSOCN";
81 cn.ConnectionString = "Network=DBMSSOCN";
82 cn.ConnectionString = "Network library=DBMSSOCN";
85 [Test]
86 public void DatabaseSynonyms()
88 SqlConnection cn = null;
90 cn = new SqlConnection ();
91 cn.ConnectionString = "Initial Catalog=db";
92 Assert.AreEqual ("db", cn.Database);
94 cn = new SqlConnection ();
95 cn.ConnectionString = "Database=db";
96 Assert.AreEqual ("db", cn.Database);
99 [Test]
100 public void DataSourceSynonyms()
102 SqlConnection cn = null;
104 cn = new SqlConnection ();
105 cn.ConnectionString = "Data Source=server";
106 Assert.AreEqual ("server", cn.DataSource);
108 cn = new SqlConnection ();
109 cn.ConnectionString = "addr=server";
110 Assert.AreEqual ("server", cn.DataSource);
112 cn = new SqlConnection ();
113 cn.ConnectionString = "address=server";
114 Assert.AreEqual ("server", cn.DataSource);
116 cn = new SqlConnection ();
117 cn.ConnectionString = "network address=server";
118 Assert.AreEqual ("server", cn.DataSource);
120 cn = new SqlConnection ();
121 cn.ConnectionString = "server=server";
122 Assert.AreEqual ("server", cn.DataSource);
125 [Test]
126 public void OtherConnectionStringKeywords()
128 SqlConnection cn = new SqlConnection ();
129 cn.ConnectionString = "Application Name=test";
130 cn.ConnectionString = "App=test";
131 cn.ConnectionString = "Connection LifeTime=1000";
132 cn.ConnectionString = "Connection Reset=true";
133 cn.ConnectionString = "Current Language=test";
134 cn.ConnectionString = "Language=test";
135 cn.ConnectionString = "Encrypt=false";
136 cn.ConnectionString = "Enlist=true";
137 cn.ConnectionString = "Integrated Security=true";
138 cn.ConnectionString = "Trusted_connection=true";
139 cn.ConnectionString = "Max Pool Size=10";
140 cn.ConnectionString = "Min Pool Size=10";
141 cn.ConnectionString = "Password=scrambled";
142 cn.ConnectionString = "Pwd=scrambled";
143 cn.ConnectionString = "Persist Security Info=true";
144 cn.ConnectionString = "PersistSecurityInfo=true";
145 cn.ConnectionString = "Pooling=true";
146 cn.ConnectionString = "User Id=test";
147 cn.ConnectionString = "User=test";
148 cn.ConnectionString = "Uid=test";
150 * NOT IMPLEMENTED YET
153 cn.ConnectionString = "Encrypt=true";
154 cn.ConnectionString = "Enlist=false";
155 cn.ConnectionString = "attachdbfilename=dunno";
156 cn.ConnectionString = "extended properties=dunno";
157 cn.ConnectionString = "initial file name=dunno";