예제 #1
0
 public static bool TryRollback(this WrappedConnection wrappedConnection)
 {
     if (wrappedConnection.CurrentTx != null)
     {
         wrappedConnection.Rollback();
         return(true);
     }
     return(false);
 }
예제 #2
0
        public void When_rollback_transaction_is_cleared()
        {
            using (var wrappedConnection = new WrappedConnection(new SqliteConnection("Data Source=:memory:")))
            {
                var tx = wrappedConnection.BeginTransaction();
                wrappedConnection.Rollback();

                Assert.Null(wrappedConnection.CurrentTx);
            }
        }
예제 #3
0
        public void Rollback_a_null_transaction_throws_InvalidOperationException()
        {
            var cnn = new SqliteConnection("Data Source=:memory:");

            using (var wrappedConnection = new WrappedConnection(cnn))
            {
                Assert.Throws <InvalidOperationException>(() => wrappedConnection.Rollback());
            }

            Assert.True(cnn.State == ConnectionState.Closed);
        }
예제 #4
0
        public void Rollback_a_null_transaction_throws_InvalidOperationException()
        {
            var cnn = _pgContainer.CreateDbConnection();

            using (var wrappedConnection = new WrappedConnection(cnn))
            {
                Assert.Throws <InvalidOperationException>(() => wrappedConnection.Rollback());
            }

            Assert.True(cnn.State == ConnectionState.Closed);
        }