public void OpenConnectionIsAccepted()
        {
            var connection = new TestDbConnection();

            connection.Open();
            Assert.DoesNotThrow(() => SutFactory(connection));
        }
        private static ConnectedSqlCommandExecutor SutFactory()
        {
            var connection = new TestDbConnection();

            connection.Open();
            return(SutFactory(connection));
        }
예제 #3
0
        public void Dispose_MultipleCallsDoNothing()
        {
            var conn   = new TestDbConnection();
            var target = new DataTransaction(conn.BeginTransaction());

            //Act
            target.Dispose();
            target.Dispose();
        }
예제 #4
0
        public void Commit_MultipleCallsFail()
        {
            var conn   = new TestDbConnection();
            var target = new DataTransaction(conn.BeginTransaction());

            target.Commit();
            Action action = () => target.Commit();

            action.Should().Throw <InvalidOperationException>();
        }
예제 #5
0
        public void Commit_DoesNotClosesConnection()
        {
            var conn   = new TestDbConnection();
            var target = new DataTransaction(conn.BeginTransaction(), false);

            //Act
            target.Commit();

            //Assert
            conn.State.Should().Be(ConnectionState.Open);
        }
예제 #6
0
        public void Commit_ClosesConnection()
        {
            var conn   = new TestDbConnection();
            var target = new DataTransaction(conn.BeginTransaction(), true);

            //Act
            target.Commit();

            //Assert
            conn.State.Should().Be(ConnectionState.Closed);
        }
예제 #7
0
        public void Ctor_DefaultClosesConnection()
        {
            //Act
            var conn   = new TestDbConnection();
            var target = new DataTransaction(conn.BeginTransaction());

            target.Commit();

            //Assert
            conn.State.Should().Be(ConnectionState.Closed);
        }
예제 #8
0
        public void Ctor_WithValidTransaction()
        {
            var conn          = new TestDbConnection();
            var expectedLevel = IsolationLevel.Snapshot;

            //Act
            var target = new DataTransaction(conn.BeginTransaction(expectedLevel));

            //Assert
            target.IsolationLevel.Should().Be(expectedLevel);
        }
예제 #9
0
        public void Dispose_IsolationLevelReset()
        {
            var conn   = new TestDbConnection();
            var target = new DataTransaction(conn.BeginTransaction());

            //Act
            target.Dispose();

            //Assert
            target.IsolationLevel.Should().Be(IsolationLevel.Unspecified);
        }
예제 #10
0
        public void Commit_RaisesEvent()
        {
            var  conn = new TestDbConnection();
            var  target = new DataTransaction(conn.BeginTransaction());
            bool wasCommitted = false, wasRolledBack = false;

            //Act
            target.Committed  += (o, e) => wasCommitted = true;
            target.RolledBack += (o, e) => wasRolledBack = true;
            target.Commit();

            //Assert
            wasCommitted.Should().BeTrue();
            wasRolledBack.Should().BeFalse();
        }
예제 #11
0
 protected override DbConnection CreateConnection(string connectionString)
 {
     Connection = new TestDbConnection();
     return(Connection);
 }