Пример #1
0
        public PipelineGlobalInboxWhenUseInboxTests()
        {
            _inbox = new InMemoryInbox();

            var registry = new SubscriberRegistry();

            registry.Register <MyCommand, MyCommandInboxedHandler>();

            var container = new ServiceCollection();

            container.AddTransient <MyCommandInboxedHandler>();
            container.AddSingleton <IAmAnInboxSync>(_inbox);
            container.AddTransient <UseInboxHandler <MyCommand> >();
            container.AddSingleton <IBrighterOptions>(new BrighterOptions()
            {
                HandlerLifetime = ServiceLifetime.Transient
            });

            var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider());


            _requestContext = new RequestContext();

            _inboxConfiguration = new InboxConfiguration(
                scope: InboxScope.All,
                onceOnly: true,
                actionOnExists: OnceOnlyAction.Throw);

            _chainBuilder = new PipelineBuilder <MyCommand>(registry, (IAmAHandlerFactorySync)handlerFactory, _inboxConfiguration);
        }
Пример #2
0
        public PipelineGlobalInboxNoInboxAttributeAsyncTests()
        {
            _inbox = new InMemoryInbox();

            var registry = new SubscriberRegistry();

            registry.RegisterAsync <MyCommand, MyNoInboxCommandHandlerAsync>();

            var container = new ServiceCollection();

            container.AddTransient <MyNoInboxCommandHandlerAsync>();
            container.AddSingleton <IAmAnInboxSync>(_inbox);
            container.AddSingleton <IBrighterOptions>(new BrighterOptions()
            {
                HandlerLifetime = ServiceLifetime.Transient
            });

            var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider());

            _requestContext = new RequestContext();

            _inboxConfiguration = new InboxConfiguration();

            _chainBuilder = new PipelineBuilder <MyCommand>(registry, (IAmAHandlerFactoryAsync)handlerFactory, _inboxConfiguration);
        }
Пример #3
0
        public OnceOnlyAttributeWithThrowExceptionTests()
        {
            _inbox = new InMemoryInbox();

            var registry = new SubscriberRegistry();

            registry.Register <MyCommand, MyStoredCommandToThrowHandler>();

            var container = new ServiceCollection();

            container.AddTransient <MyStoredCommandToThrowHandler>();
            container.AddSingleton(_inbox);
            container.AddTransient <UseInboxHandler <MyCommand> >();
            container.AddSingleton <IBrighterOptions>(new BrighterOptions()
            {
                HandlerLifetime = ServiceLifetime.Transient
            });

            var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider());

            _command = new MyCommand {
                Value = "My Test String"
            };

            _commandProcessor = new CommandProcessor(registry, handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry());
        }
        public CommandProcessorUsingInboxTests()
        {
            _inbox = new InMemoryInbox();

            var registry = new SubscriberRegistry();

            registry.Register <MyCommand, MyStoredCommandHandler>();
            registry.Register <MyCommandToFail, MyStoredCommandToFailHandler>();

            var container = new ServiceCollection();

            container.AddTransient <MyStoredCommandHandler>();
            container.AddTransient <MyStoredCommandToFailHandler>();
            container.AddSingleton(_inbox);
            container.AddTransient <UseInboxHandler <MyCommand> >();
            container.AddTransient <UseInboxHandler <MyCommandToFail> >();
            container.AddSingleton <IBrighterOptions>(new BrighterOptions()
            {
                HandlerLifetime = ServiceLifetime.Transient
            });

            var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider());

            _command = new MyCommand {
                Value = "My Test String"
            };

            _contextKey       = typeof(MyStoredCommandHandler).FullName;
            _commandProcessor = new CommandProcessor(registry, handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry());
        }
        public PipelineGlobalInboxContextTests()
        {
            _inbox = new InMemoryInbox();

            var registry = new SubscriberRegistry();

            registry.Register <MyCommand, MyGlobalInboxCommandHandler>();

            var container = new ServiceCollection();

            container.AddTransient <MyGlobalInboxCommandHandler>();
            container.AddSingleton <IAmAnInboxSync>(_inbox);
            container.AddTransient <UseInboxHandler <MyCommand> >();
            container.AddSingleton <IBrighterOptions>(new BrighterOptions()
            {
                HandlerLifetime = ServiceLifetime.Transient
            });

            var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider());

            _requestContext = new RequestContext();

            _inboxConfiguration = new InboxConfiguration(
                scope: InboxScope.All,
                context: (handlerType) => CONTEXT_KEY);

            _chainBuilder = new PipelineBuilder <MyCommand>(registry, (IAmAHandlerFactorySync)handlerFactory, _inboxConfiguration);
            PipelineBuilder <MyCommand> .ClearPipelineCache();
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RequestHandler{TRequest}" /> class.
 /// </summary>
 /// <param name="inbox">The store for commands that pass into the system</param>
 public UseInboxHandler(IAmAnInboxSync inbox)
 {
     _inbox = inbox;
 }