2 * Firebird ADO.NET Data provider for .NET and Mono
4 * The contents of this file are subject to the Initial
5 * Developer's Public License Version 1.0 (the "License");
6 * you may not use this file except in compliance with the
7 * License. You may obtain a copy of the License at
8 * http://www.firebirdsql.org/index.php?op=doc&id=idpl
10 * Software distributed under the License is distributed on
11 * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
12 * express or implied. See the License for the specific
13 * language governing rights and limitations under the License.
15 * Copyright (c) 2002, 2004 Carlos Guzman Alvarez
16 * All Rights Reserved.
19 using NUnit.Framework;
23 using FirebirdSql.Data.Firebird;
25 namespace FirebirdSql.Data.Firebird.Tests
28 public class FbTransactionTest : BaseTest
30 public FbTransactionTest() : base(false)
35 public void DisposeTest()
40 FbCommand cmd = new FbCommand("select * from test", this.Connection);
41 cmd.Transaction = this.Connection.BeginTransaction(IsolationLevel.RepeatableRead);
43 FbDataReader r = cmd.ExecuteReader();
49 cmd.Transaction.Rollback();
50 cmd.Transaction.Dispose();
61 throw new Exception("Incorrect Dispose behavior");
67 public void CommitTest()
69 Transaction = Connection.BeginTransaction();
74 public void RollbackTest()
76 Transaction = Connection.BeginTransaction();
77 Transaction.Rollback();
81 public void SavePointTest()
83 FbCommand command = new FbCommand();
85 Console.WriteLine("Iniciada nueva transaccion");
87 Transaction = Connection.BeginTransaction("InitialSavePoint");
89 command.Connection = Connection;
90 command.Transaction = Transaction;
92 command.CommandText = "insert into TEST (INT_FIELD) values (200) ";
93 command.ExecuteNonQuery();
95 Transaction.Save("FirstSavePoint");
97 command.CommandText = "insert into TEST (INT_FIELD) values (201) ";
98 command.ExecuteNonQuery();
99 Transaction.Save("SecondSavePoint");
101 command.CommandText = "insert into TEST (INT_FIELD) values (202) ";
102 command.ExecuteNonQuery();
103 Transaction.Rollback("InitialSavePoint");
105 Transaction.Commit();
110 public void AbortTransaction()
112 StringBuilder b1 = new StringBuilder();
113 b1.AppendFormat("ALTER TABLE \"{0}\" drop \"INT_FIELD\"", "TEST");
115 FbTransaction transaction = null;
116 FbCommand command = null;
120 transaction = this.Connection.BeginTransaction();
122 command = new FbCommand(b1.ToString(), this.Connection, transaction);
123 command.ExecuteNonQuery();
125 transaction.Commit();
130 transaction.Rollback();