public void Open_WithRetry() { IConnectionFactory factory = new SqlServerConnectionFactoryWithRetry(10, TimeSpan.FromSeconds(30)); using (var connection = factory.Open(AppState.ConnectionString)) { Assert.IsNotNull(connection); Assert.AreEqual(ConnectionState.Open, connection.State); connection.Close(); } }
public void BeginTransaction_WithIsolationLevel_WithRetry() { var retryPolicy = new SqlServerTransientRetryPolicy(10, TimeSpan.FromSeconds(60)); ITransactionFactory transactionFactory = new SqlServerTransactionFactoryWithRetry(retryPolicy); IConnectionFactory connectionFactory = new SqlServerConnectionFactoryWithRetry(retryPolicy); using (var connection = connectionFactory.Open(AppState.ConnectionString)) using (var transaction = transactionFactory.BeginTransaction(connection, IsolationLevel.Snapshot)) { Assert.IsNotNull(transaction); Assert.AreEqual(connection, transaction.Connection); Assert.AreEqual(IsolationLevel.Snapshot, transaction.IsolationLevel); transaction.Rollback(); } }
public void BeginTransaction_WithRetry() { var retryOptions = new RetryOptions(10, TimeSpan.FromSeconds(60)); ITransactionFactory transactionFactory = new SqlServerTransactionFactoryWithRetry(retryOptions); IConnectionFactory connectionFactory = new SqlServerConnectionFactoryWithRetry(retryOptions); using (var connection = connectionFactory.Open(AppState.ConnectionString)) using (var transaction = transactionFactory.BeginTransaction(connection)) { Assert.IsNotNull(transaction); Assert.AreEqual(connection, transaction.Connection); Assert.AreEqual(IsolationLevel.ReadCommitted, transaction.IsolationLevel); transaction.Rollback(); } }