public async Task ExecuteAsync_CommonException_HandlesException() { var exceptionHandler = new SyncPingCommonExceptionHandler(); var middleware = new ExceptionHandlingMiddleware <Ping, int>(new[] { exceptionHandler }); var query = new Ping(); var handler = new BrokenPingHandler(); var actual = await middleware.ExecuteAsync( query, () => handler.HandleAsync(query, default), default ); actual.Should().Be(exceptionHandler.Value); }
public async Task ExecuteAsync_MultipleExceptionHandlers_UsesConcreteHandler() { var concreteExceptionHandler = new SyncPingConcreteExceptionHandler(); var middleware = new ExceptionHandlingMiddleware <Ping, int>( new IQueryExceptionHandler <Ping, int>[] { new SyncPingCommonExceptionHandler(), concreteExceptionHandler } ); var query = new Ping(); var handler = new BrokenPingHandler(); var actual = await middleware.ExecuteAsync( query, () => handler.HandleAsync(query, default), default ); actual.Should().Be(concreteExceptionHandler.Value); }