public void Execute_throws_on_null_parameters() { var executionStrategy = new DefaultSqlExecutionStrategy(); Assert.Equal( "action", Assert.Throws<ArgumentNullException>(() => executionStrategy.Execute(null)).ParamName); Assert.Equal( "func", Assert.Throws<ArgumentNullException>(() => executionStrategy.Execute((Func<object>)null)).ParamName); }
private void Execute_doesnt_retry_on_nontransient_exceptions(Action<IExecutionStrategy, Func<int>> execute) { var executionStrategy = new DefaultSqlExecutionStrategy(); var executionCount = 0; Assert.Throws<ArgumentException>( () => execute( executionStrategy, () => { executionCount++; throw new ArgumentException(); })); Assert.Equal(1, executionCount); }
private void Execute_doesnt_retry_on_transient_exceptions(Action<IExecutionStrategy, Func<int>> execute) { var executionStrategy = new DefaultSqlExecutionStrategy(); var executionCount = 0; var exception = Assert.Throws<EntityException>( () => execute( executionStrategy, () => { executionCount++; throw new TimeoutException(); })); Assert.IsType<TimeoutException>(exception.InnerException); exception.ValidateMessage( TestBase.EntityFrameworkSqlServerAssembly, "TransientExceptionDetected", "System.Data.Entity.SqlServer.Properties.Resources.SqlServer"); Assert.Equal(1, executionCount); }
public void ExecuteAsync_throws_on_null_parameter() { var executionStrategy = new DefaultSqlExecutionStrategy(); Assert.Equal( "func", Assert.Throws<ArgumentNullException>(() => executionStrategy.ExecuteAsync((Func<Task<object>>)null, CancellationToken.None)).ParamName); Assert.Equal( "func", Assert.Throws<ArgumentNullException>(() => executionStrategy.ExecuteAsync((Func<Task<object>>)null, CancellationToken.None)).ParamName); }
private void ExecuteAsync_doesnt_retry_on_nontransient_exceptions(Func<IExecutionStrategy, Func<Task<int>>, Task> executeAsync) { var executionStrategy = new DefaultSqlExecutionStrategy(); var executionCount = 0; Assert.Throws<ArgumentException>( () => ExceptionHelpers.UnwrapAggregateExceptions( () => executeAsync( executionStrategy, () => { executionCount++; throw new ArgumentException(); }).Wait())); Assert.Equal(1, executionCount); }
private void ExecuteAsync_doesnt_retry_on_transient_exceptions(Func<IDbExecutionStrategy, Func<Task<int>>, Task> executeAsync) { var executionStrategy = new DefaultSqlExecutionStrategy(); var executionCount = 0; var exception = Assert.Throws<EntityException>( () => ExceptionHelpers.UnwrapAggregateExceptions( () => executeAsync( executionStrategy, () => { executionCount++; throw new TimeoutException(); }).Wait())); Assert.IsType<TimeoutException>(exception.InnerException); exception.ValidateMessage( TestBase.EntityFrameworkSqlServerAssembly, "TransientExceptionDetected", "System.Data.Entity.SqlServer.Properties.Resources.SqlServer"); Assert.Equal(1, executionCount); }