public static IServiceCollection AddV1Mediators(this IServiceCollection services) { var builder = new PipelineProviderBuilder(); AddIdentitiesUsersMediator(builder); var pipelineProvider = builder.Build(); services.AddTransient <GetService>(c => c.GetService); services.AddTransient(c => pipelineProvider); services.AddTransient <IMediator, Mediator>(); return(services); }
public void BuildSendAsyncPipeline_ThrowsPipelineAlreadyExistsException() { var services = new ServiceCollection(); var pipelineProviderBuilder = new PipelineProviderBuilder(); pipelineProviderBuilder.On <PingRequest>().PipelineAsync() .Return <PingResponse, IPingHandler>( (handler, req) => handler.MyCustomFooBarAsync(req) ); pipelineProviderBuilder.On <PingRequest>().PipelineAsync() .Return <PingResponse, IPingHandler>( (handler, req) => handler.MyCustomFooBarAsync(req) ); Exception ex = Record.Exception(() => pipelineProviderBuilder.Build()); Assert.NotNull(ex); Assert.IsType <PipelineAlreadyExistsException>(ex); }