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 SetUp() { _connectionManager = new Mock<IDatabaseCommandProvider>(); _dbCommand = new Mock<IDbCommand>(); _dataParameter = new Mock<IDbDataParameter>(); _dataParmeterCollection = new Mock<IDataParameterCollection>(); _databaseCommandFactory = new DatabaseCommandFactory(_connectionManager.Object); _connectionManager.Setup(x => x.CreateCommandForCurrentConnection()).Returns(_dbCommand.Object); _dbCommand.Setup(x => x.CreateParameter()).Returns(_dataParameter.Object); _dbCommand.Setup(x => x.Parameters).Returns(_dataParmeterCollection.Object); }