コード例 #1
0
        public async Task ShouldNotExecutePipelineHandlersIfPipelineIsDisabledAsync()
        {
            var handler         = new EventHandler();
            var pipelineHandler = new EventPipelineHandler();

            var container = new Container(x =>
            {
                x.Add <IEventHandler <Event> >().Instance(handler);
                x.Add <IEventPipelineHandler <Event> >().Instance(pipelineHandler);
            });

            var mediator = new Mediator(container.GetService);

            await Task.WhenAll(mediator.Publish(new Event()));

            handler.Executed.ShouldBeTrue();
            pipelineHandler.Executed.ShouldBeFalse();
        }
コード例 #2
0
        public async Task ShouldExecuteEventPipelineHandlers()
        {
            var handler         = new EventHandler();
            var pipelineHandler = new EventPipelineHandler();

            var container = new Container(x =>
            {
                x.Add <IEventHandler <Event> >().Instance(handler);
                x.Add <IEventPipelineHandler <Event> >().Instance(pipelineHandler);
            });

            var mediator = new Mediator(container.GetService, new Configuration {
                EventPipelineEnabled = true
            });

            await Task.WhenAll(mediator.Publish(new Event()));

            handler.Executed.ShouldBeTrue();
            pipelineHandler.Executed.ShouldBeTrue();
        }