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); }
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); }