public void ExecuteWithinTransactionScope_WhenDBConnectionIsProvided_TransactionIsExecuted() { // Act _testee.ExecuteWithinTransactionScope(connection => { connection.Should().Be(_dbConnection); }); // Assert A.CallTo(() => _sqlConnectionFactory.CreateOpenedReliableConnection(A <string> .Ignored)).MustHaveHappened(); }
public TReturnValue ExecuteScalar <TReturnValue>(Func <IDbConnection, TReturnValue> action) { using (_connectionThrottleGuard.ExecuteGuarded()) using (var connection = _sqlConnectionFactory.CreateOpenedReliableConnection(_connectionString)) { return(action(connection)); } }
public void TestInitialize() { _dbConnection = A.Fake <IDbConnection>(); _sqlConnectionFactory = A.Fake <ISqlConnectionFactory>(); var connectionThrottleGuard = A.Fake <IConnectionThrottleGuard>(); _testee = new UnitOfWork("someConnectionString", _sqlConnectionFactory, connectionThrottleGuard); A.CallTo(() => _sqlConnectionFactory.CreateOpenedReliableConnection(A <string> .Ignored)).Returns(_dbConnection); }