-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement dispose for Connection and Transaction. Add test cases as w…
…ell.
- Loading branch information
1 parent
b2becaf
commit 4bb3eb4
Showing
4 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2012-2019 Snowflake Computing Inc. All rights reserved. | ||
*/ | ||
|
||
namespace Snowflake.Data.Tests | ||
{ | ||
using NUnit.Framework; | ||
using Snowflake.Data.Client; | ||
using System.Data; | ||
|
||
[TestFixture] | ||
class SFDbTransactionIT : SFBaseTest | ||
{ | ||
[Test] | ||
// Test that when a transaction is disposed, rollback would be sent out | ||
public void TestTransactionDispose() | ||
{ | ||
var conn = new SnowflakeDbConnection(); | ||
try | ||
{ | ||
conn.ConnectionString = connectionString; | ||
conn.Open(); | ||
|
||
IDbCommand command = conn.CreateCommand(); | ||
command.CommandText = "create or replace table testTransactionDispose(c int)"; | ||
command.ExecuteNonQuery(); | ||
|
||
using (IDbTransaction t1 = conn.BeginTransaction()) | ||
{ | ||
IDbCommand t1c1 = conn.CreateCommand(); | ||
t1c1.Transaction = t1; | ||
t1c1.CommandText = "insert into testTransactionDispose values (1)"; | ||
t1c1.ExecuteNonQuery(); | ||
} | ||
|
||
// Transaction t1 would be disposed and rollback at this point, tuple inserted is not visible | ||
IDbCommand c2 = conn.CreateCommand(); | ||
c2.CommandText = "SELECT * FROM testTransactionDispose"; | ||
IDataReader reader2 = c2.ExecuteReader(); | ||
Assert.IsFalse(reader2.Read()); | ||
} | ||
finally | ||
{ | ||
IDbCommand command = conn.CreateCommand(); | ||
command.CommandText = "DROP TABLE IF EXISTS testTransactionDispose"; | ||
command.ExecuteNonQuery(); | ||
conn.Close(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters