1 // project created on 30/11/2002 at 22:00
4 // Francisco Figueiredo Jr. <fxjrlists@yahoo.com>
6 // Copyright (C) 2002 The Npgsql Development Team
7 // npgsql-general@gborg.postgresql.org
8 // http://gborg.postgresql.org/project/npgsql/projdisplay.php
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 using NUnit
.Framework
;
36 public class ConnectionTests
38 NpgsqlConnection _conn
;
41 protected void SetUp()
43 //NpgsqlEventLog.Level = LogLevel.None;
44 //NpgsqlEventLog.Level = LogLevel.Debug;
45 //NpgsqlEventLog.LogName = "NpgsqlTests.LogFile";
46 _conn
= new NpgsqlConnection (TestConfiguration
.NpgsqlConnectionString
);
50 protected void TearDown()
62 //Assert.AreEqual("ConnectionOpen", ConnectionState.Open, _conn.State);
65 Console
.WriteLine(e
.ToString());
72 public void ChangeDatabase()
76 _conn
.ChangeDatabase("template1");
78 NpgsqlCommand command
= new NpgsqlCommand("select current_database()", _conn
);
80 String result
= (String
)command
.ExecuteScalar();
82 Assert
.AreEqual("template1", result
);
87 [ExpectedException(typeof(InvalidOperationException
))]
88 public void NestedTransaction()
92 NpgsqlTransaction t
= null;
95 t
= _conn
.BeginTransaction();
97 t
= _conn
.BeginTransaction();
101 // Catch exception so we call rollback the transaction initiated.
102 // This way, the connection pool doesn't get a connection with a transaction
111 public void SequencialTransaction()
115 NpgsqlTransaction t
= _conn
.BeginTransaction();
119 t
= _conn
.BeginTransaction();