Skip to content

Commit

Permalink
Passing test for rollback on ambient transaction timeout
Browse files Browse the repository at this point in the history
For issue #495
  • Loading branch information
roji committed Mar 4, 2015
1 parent 0b25de1 commit fb82fca
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/SystemTransactionsTest.cs
Expand Up @@ -134,6 +134,27 @@ public void TwoDistributedInSequence()
DistributedTransactionRollback();
}

[Test, Description("Makes sure that when a timeout occurs, the transaction is rolled backed")]
[IssueLink("https://github.com/npgsql/npgsql/issues/495")]
public void RollbackOnTimeout()
{
Assert.That(() =>
{
using (var scope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 0, 1)))
{
using (var conn = new NpgsqlConnection(ConnectionString + ";enlist=true"))
{
conn.Open();
var cmd = new NpgsqlCommand(@"INSERT INTO data (field_text) VALUES ('HELLO')", conn);
cmd.ExecuteNonQuery(); // the update operation is expected to rollback
System.Threading.Thread.Sleep(2000);
}
scope.Complete();
}
}, Throws.Exception.TypeOf<TransactionAbortedException>());
Assert.That(ExecuteScalar("SELECT COUNT(*) FROM data"), Is.EqualTo(0));
}

[Test, Description("Not sure what this test is supposed to check...")]
public void FunctionTestTimestamptzParameterSupport()
{
Expand Down

0 comments on commit fb82fca

Please sign in to comment.