Ejemplo n.º 1
0
 public static bool TryCommit(this WrappedConnection wrappedConnection)
 {
     if (wrappedConnection.CurrentTx != null)
     {
         wrappedConnection.Commit();
         return(true);
     }
     return(false);
 }
Ejemplo n.º 2
0
        public void When_commit_transaction_is_cleared()
        {
            using (var wrappedConnection = new WrappedConnection(new SqliteConnection("Data Source=:memory:")))
            {
                var tx = wrappedConnection.BeginTransaction();
                wrappedConnection.Commit();

                Assert.Null(wrappedConnection.CurrentTx);
            }
        }
Ejemplo n.º 3
0
        public void Commit_a_null_transaction_throws_InvalidOperationException()
        {
            var cnn = new SqliteConnection("Data Source=:memory:");

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

            Assert.True(cnn.State == ConnectionState.Closed);
        }
Ejemplo n.º 4
0
        public void Commit_a_null_transaction_throws_InvalidOperationException()
        {
            var cnn = _pgContainer.CreateDbConnection();

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

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