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