コード例 #1
0
        public void ExecuteWithinTransactionScope_WhenDBConnectionIsProvided_TransactionIsExecuted()
        {
            // Act
            _testee.ExecuteWithinTransactionScope(connection => { connection.Should().Be(_dbConnection); });

            // Assert
            A.CallTo(() => _sqlConnectionFactory.CreateOpenedReliableConnection(A <string> .Ignored)).MustHaveHappened();
        }
コード例 #2
0
 public TReturnValue ExecuteScalar <TReturnValue>(Func <IDbConnection, TReturnValue> action)
 {
     using (_connectionThrottleGuard.ExecuteGuarded())
         using (var connection = _sqlConnectionFactory.CreateOpenedReliableConnection(_connectionString))
         {
             return(action(connection));
         }
 }
コード例 #3
0
        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);
        }