public void ShouldNotCloseClosedConnectionDuringCleanUp()
        {
            _connectionMock.Setup(x => x.State).Returns(ConnectionState.Closed);
            var connectionHandler = new ConnectionHandler().GetHandler(_dbCommandMock.Object, _transactionWrapperMock.Object);

            connectionHandler.RollbackTransactionAndCloseConnection();

            _connectionMock.Verify(x => x.Close(), Times.Never());
        }
 public IDatabaseSession CreateSession(string connectionString)
 {
     var sqlConnectionProvider = _connectionProvider ?? new SqlConnectionProvider(connectionString);
     var transactionWrapper = new TransactionWrapper(sqlConnectionProvider);
     var databaseConnectionManager = new DatabaseCommandProvider(sqlConnectionProvider, transactionWrapper);
     var databaseCommandCreator = new DatabaseCommandFactory(databaseConnectionManager);
     var databaseReaderFactory = new SqlDatabaseReaderFactory();
     var connectionHandler = new ConnectionHandler();
     return new DatabaseSession(databaseCommandCreator, transactionWrapper, databaseReaderFactory, connectionHandler);
 }
        public void ShouldNotRollbackTransactionWhenNoTransactionIsInProgress()
        {
            _transactionWrapperMock.Setup(x => x.TransactionInProgress).Returns(false);
            var connectionHandler = new ConnectionHandler().GetHandler(_dbCommandMock.Object, _transactionWrapperMock.Object);

            connectionHandler.RollbackTransactionAndCloseConnection();

            _transactionWrapperMock.Verify(x => x.Rollback(), Times.Never());
        }