public void DoNotCheckResponseIfNullCheckIgnoreIsSet() { var options = new NullCheckPostProcessorOptions(); options.IgnoreRequest <Request>(); var postProcessor = new NullCheckPostProcessor <Request, string>(options); Action action = () => postProcessor.Process(new Request(), null, CancellationToken.None); action.Should().NotThrow <NotFoundException>(); }
/// <summary> /// Add <see cref="NullCheckPostProcessor{TRequest, TResponse}"/> for MediatR. /// </summary> /// <param name="services">Service container.</param> /// <param name="optionAction">Configure which requests will be ignore.</param> public static IServiceCollection AddMediatRNullCheckPostProcessor( this IServiceCollection services, Action <NullCheckPostProcessorOptions> optionAction) { var options = new NullCheckPostProcessorOptions(); optionAction(options); services.AddSingleton(options); services.AddSingleton(typeof(IRequestPostProcessor <,>), typeof(NullCheckPostProcessor <,>)); return(services); }