2 // MSSqlTestBed.cs : This is base class which manages the connections to
3 // MSSql database. This serves as a base class for all
4 // MSSql database dependant tests.
8 // * compile using following command
9 // mcs /r:System.Data.dll,nunit.framework.dll /t:library /debug
10 // /out:MSSqlTestBed.dll MSSqlTestBed.cs System.Data.Common/*.cs
12 // mono /usr/local/bin/nunit-console.exe MSSqlTestBed.dll
15 // Umadevi S (sumadevi@novell.com)
17 // Copyright (c) 2004 Novell Inc., and the individuals listed
18 // on the ChangeLog entries.
20 // Permission is hereby granted, free of charge, to any person obtaining
21 // a copy of this software and associated documentation files (the
22 // "Software"), to deal in the Software without restriction, including
23 // without limitation the rights to use, copy, modify, merge, publish,
24 // distribute, sublicense, and/or sell copies of the Software, and to
25 // permit persons to whom the Software is furnished to do so, subject to
26 // the following conditions:
28 // The above copyright notice and this permission notice shall be
29 // included in all copies or substantial portions of the Software.
31 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 using System.Data.Common;
43 using System.Data.SqlClient;
44 using System.Collections.Specialized;
46 namespace MonoTests.System.Data
48 public class MSSqlTestClient
50 #region protected members
51 protected string connectionString = null;
52 protected SqlConnection conn = null;
53 protected bool isConnAlive = false;
56 public MSSqlTestClient ()
59 "Server=164.99.168.131;" +
60 "Database=Northwind;" +
63 conn = new SqlConnection(connectionString);
66 protected void OpenConnection ()
68 conn.ConnectionString = connectionString;
70 // run tests only if the connection is open,
71 // otherwise make it fail, to setup with correct
73 if (conn != null && conn.State != ConnectionState.Closed)
77 protected void CloseConnection ()
79 if (conn != null && conn.State != ConnectionState.Closed) {
85 internal void ExecuteQuery (string query)
87 SqlCommand cmd = new SqlCommand ();
88 cmd.Connection = conn;
89 cmd.CommandText = query;
91 int recordsAff = cmd.ExecuteNonQuery ();
92 } catch (Exception e) {
93 Console.WriteLine("exception");
94 Console.WriteLine(e.StackTrace);