public async Task Given_ConfiguredRequest_When_Process_Then_HandlersCalledAfterPredicate() { var context = new DefaultHttpContext(); A.CallTo(() => _predicate.Invoke(A <IWebRequestEvent> ._)).Returns(true); await _sut.ProcessAsync(context); A.CallTo(() => _eventHandlerFactory.Create(A <IEnumerable <IEventHandlerSpecification <IWebRequest> > > .That.Contains(_handlerSpec))).MustHaveHappened(); A.CallTo(() => _predicate.Invoke(A <IWebRequestEvent> ._)).MustHaveHappened().Then( A.CallTo(() => _responseFactory.Invoke(A <IWebResponse> ._)).MustHaveHappened()); A.CallTo(() => _predicate.Invoke(A <IWebRequestEvent> ._)).MustHaveHappened().Then( A.CallTo(() => _eventHandler.ExecuteHandlersAsync(A <IWebRequest> ._, A <CancellationToken> ._)).MustHaveHappened()); }
public IComponent Apply(IHostBuilder hostBuilder) { var component = new WebComponent(); hostBuilder.ConfigureWebHostDefaults(w => { ConfigreBuilderAction?.Invoke(w); w.Configure(app => { app.Use(async(context, next) => { await component.ProcessAsync(context); await next(); }); }); }); return(component); }