Пример #1
0
        private static IEventBus InitializeEventBus(IEventHandler<NewNoteAdded> handler, TextChangedHandler textChangedHandler)
        {
            var bus = new InProcessEventBus();
            bus.RegisterHandler(handler);
            bus.RegisterHandler(textChangedHandler);

            return bus;
        }
Пример #2
0
        private static IEventBus InitializeEventBus(IEventHandler <NewNoteAdded> handler, TextChangedHandler textChangedHandler)
        {
            var bus = new InProcessEventBus();

            bus.RegisterHandler(handler);
            bus.RegisterHandler(textChangedHandler);

            return(bus);
        }
Пример #3
0
        private static IEventBus InitializeEventBus()
        {
            var bus = new InProcessEventBus();
            bus.RegisterHandler(new VoyageCreatedDenormalizer());
            bus.RegisterHandler(new CargoCreatedDenormalizer());
            bus.RegisterHandler(new CargoAddedToVoyageUpdateCapacityDenormalizer());
            bus.RegisterHandler(new CargoAddedToVoyageUpdateCargoDenormalizer());

            return bus;
        }
Пример #4
0
        private static IEventBus InitializeEventBus(IKernel kernel)
        {
            var bus = new InProcessEventBus();
              bus.RegisterHandler<MeetingScheduledEvent>
            (kernel.Get<MeetingDenormalizer>());
              bus.RegisterHandler<MeetingScheduledEvent>
            (kernel.Get<StatDenormalizer>());

              bus.RegisterHandler<CommentAddedEvent>
            (kernel.Get<MeetingDenormalizer>());
              bus.RegisterHandler<CommentAddedEvent>
            (kernel.Get<StatDenormalizer>());

              return bus;
        }
Пример #5
0
        private static IEventBus InitializeEventBus()
        {
            var bus = new InProcessEventBus();
            bus.RegisterHandler( new TweetListItemDenormalizer() );

            return bus;
        }
Пример #6
0
        private static IEventBus InitializeEventBus(InMemoryBufferedBrowsableElementStore buffer)
        {
            var bus = new InProcessEventBus();

            bus.RegisterHandler(new InMemoryBufferedEventHandler(buffer));

            return(bus);
        }
        private static IEventBus InitializeEventBus()
        {
            var bus = new InProcessEventBus();

            bus.RegisterHandler(new TweetListItemDenormalizer());

            return(bus);
        }
Пример #8
0
        private static IEventBus InitializeEventBus(InMemoryBufferedBrowsableElementStore buffer)
        {
            var bus = new InProcessEventBus();

            bus.RegisterHandler(new InMemoryBufferedEventHandler(buffer));

            return bus;
        }
Пример #9
0
        public void When_a_catch_all_handler_is_register_it_should_be_called_for_all_events()
        {
            var catchAllEventHandler = MockRepository.GenerateMock<IEventHandler<object>>();

            var bus = new InProcessEventBus();
            bus.RegisterHandler(catchAllEventHandler);

            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());

            catchAllEventHandler.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Twice());
        }
Пример #10
0
        public void When_a_catch_all_handler_is_register_it_should_be_called_for_all_events()
        {
            var catchAllEventHandler = MockRepository.GenerateMock <IEventHandler <object> >();

            var bus = new InProcessEventBus();

            bus.RegisterHandler(catchAllEventHandler);

            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());

            catchAllEventHandler.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Twice());
        }
Пример #11
0
        public void When_a_multiple_catch_all_handler_are_registered_for_they_should_all_been_called()
        {
            var catchAllEventHandler1 = MockRepository.GenerateMock<IEventHandler<object>>();
            var catchAllEventHandler2 = MockRepository.GenerateMock<IEventHandler<object>>();
            var catchAllEventHandler3 = MockRepository.GenerateMock<IEventHandler<object>>();

            var bus = new InProcessEventBus();
            bus.RegisterHandler(catchAllEventHandler1);
            bus.RegisterHandler(catchAllEventHandler2);
            bus.RegisterHandler(catchAllEventHandler3);

            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());

            catchAllEventHandler1.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(7));
            catchAllEventHandler2.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(7));
            catchAllEventHandler3.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(7));
        }
Пример #12
0
        public void When_a_multiple_specific_handlers_are_register_they_all_should_be_called_when_the_specific_event_is_published()
        {
            var specificEventHandler1 = MockRepository.GenerateMock <IEventHandler <ADomainEvent> >();
            var specificEventHandler2 = MockRepository.GenerateMock <IEventHandler <ADomainEvent> >();
            var specificEventHandler3 = MockRepository.GenerateMock <IEventHandler <ADomainEvent> >();

            var bus = new InProcessEventBus();

            bus.RegisterHandler(specificEventHandler1);
            bus.RegisterHandler(specificEventHandler2);
            bus.RegisterHandler(specificEventHandler3);

            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());

            specificEventHandler1.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(2));
            specificEventHandler2.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(2));
            specificEventHandler3.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(2));
        }
Пример #13
0
        public void When_a_multiple_catch_all_handler_are_registered_for_they_should_all_been_called()
        {
            var catchAllEventHandler1 = MockRepository.GenerateMock <IEventHandler <object> >();
            var catchAllEventHandler2 = MockRepository.GenerateMock <IEventHandler <object> >();
            var catchAllEventHandler3 = MockRepository.GenerateMock <IEventHandler <object> >();

            var bus = new InProcessEventBus();

            bus.RegisterHandler(catchAllEventHandler1);
            bus.RegisterHandler(catchAllEventHandler2);
            bus.RegisterHandler(catchAllEventHandler3);

            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());

            catchAllEventHandler1.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(7));
            catchAllEventHandler2.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(7));
            catchAllEventHandler3.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(7));
        }
Пример #14
0
        private static IEventBus InitializeEventBus()
        {
            var bus = new InProcessEventBus();
            //bus.RegisterHandler(new SqlTweetIndexItemDenormalizer());
            bus.RegisterHandler(new FileTweetIndexItemDenormalizer());
            bus.RegisterHandler(new FileTweetIndexItemDeleteDenormalizer());
            bus.RegisterHandler(new ChannelIndexItemDenormalizer());
            bus.RegisterHandler(new UserIndexDenormalizer());
            bus.RegisterHandler(new UserIndexDeleteDenormalizer());
            bus.RegisterHandler(new UserIndexPropertySetDenormalizer());
            bus.RegisterHandler(new UserIndexPasswordSetDenormalizer());

            return bus;
        }
        public void When_multiple_messages_are_published_at_once_they_all_should_be_published()
        {

            var catchAllEventHandler = MockRepository.GenerateMock<IEventHandler<object>>();
            var bus = new InProcessEventBus();
            bus.RegisterHandler(catchAllEventHandler);

            var events = new[]
                             {
                                 CreateAEvent(), CreateAEvent(), CreateAEvent(), CreateAEvent(), CreateAEvent(), CreateAEvent(),
                                 CreateAEvent(), CreateAEvent(), CreateAEvent(), CreateAEvent(), CreateAEvent(), CreateAEvent()
                             };

            bus.Publish(events);

            catchAllEventHandler.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(events.Length));
        }
Пример #16
0
        public void When_multiple_messages_are_published_and_a_specific_handler_is_register_oply_the_matching_events_should_be_received_at_the_handler()
        {
            var aDomainEventHandler = MockRepository.GenerateMock <IEventHandler <ADomainEvent> >();
            var bus = new InProcessEventBus();

            bus.RegisterHandler(aDomainEventHandler);

            var events = new IPublishableEvent[]
            {
                CreateAEvent(), CreateADomainEvent(), CreateADomainEvent(), CreateAEvent(), CreateADomainEvent(), CreateAEvent(),
                CreateAEvent(), CreateADomainEvent(), CreateADomainEvent(), CreateAEvent(), CreateADomainEvent(), CreateAEvent()
            };

            bus.Publish(events);

            aDomainEventHandler.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(6));
        }
Пример #17
0
        public void When_multiple_messages_are_published_at_once_they_all_should_be_published()
        {
            var catchAllEventHandler = MockRepository.GenerateMock <IEventHandler <object> >();
            var bus = new InProcessEventBus();

            bus.RegisterHandler(catchAllEventHandler);

            var events = new[]
            {
                CreateAEvent(), CreateAEvent(), CreateAEvent(), CreateAEvent(), CreateAEvent(), CreateAEvent(),
                CreateAEvent(), CreateAEvent(), CreateAEvent(), CreateAEvent(), CreateAEvent(), CreateAEvent()
            };

            bus.Publish(events);

            catchAllEventHandler.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(events.Length));
        }
Пример #18
0
        public void Registering_handler_via_generic_overload_should_also_add_the_handler()
        {
            var aDomainEventHandler = MockRepository.GenerateMock<IEventHandler<ADomainEvent>>();
            var bus = new InProcessEventBus();

            bus.RegisterHandler(aDomainEventHandler);

            var events = new IPublishableEvent[]
                             {
                                 CreateAEvent(), CreateADomainEvent(), CreateADomainEvent(), CreateAEvent(), CreateADomainEvent(), CreateAEvent(),
                                 CreateAEvent(), CreateADomainEvent(), CreateADomainEvent(), CreateAEvent(), CreateADomainEvent(), CreateAEvent()
                             };

            bus.Publish(events);

            aDomainEventHandler.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(6));
        }
Пример #19
0
        public void Registering_handler_via_generic_overload_should_also_add_the_handler()
        {
            var aDomainEventHandler = MockRepository.GenerateMock <IEventHandler <ADomainEvent> >();
            var bus = new InProcessEventBus();

            bus.RegisterHandler(aDomainEventHandler);

            var events = new IPublishableEvent[]
            {
                CreateAEvent(), CreateADomainEvent(), CreateADomainEvent(), CreateAEvent(), CreateADomainEvent(), CreateAEvent(),
                CreateAEvent(), CreateADomainEvent(), CreateADomainEvent(), CreateAEvent(), CreateADomainEvent(), CreateAEvent()
            };

            bus.Publish(events);

            aDomainEventHandler.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(6));
        }
Пример #20
0
        public void Configure(Configure config)
        {
            Builder    = config.Builder;
            Configurer = config.Configurer;

            NcqrsEnvironment.Configure(new NsbEnvironmentConfiguration(Builder));
            var compositeBus = new CompositeEventBus();

            _inProcessEventBus = new InProcessEventBus(false);
            compositeBus.AddBus(new NsbEventBus());
            compositeBus.AddBus(_inProcessEventBus);
            _sendingEventHandler = new MessageSendingEventHandler();
            _inProcessEventBus.RegisterHandler(_sendingEventHandler);
            NcqrsEnvironment.SetDefault(compositeBus);
            _messageService = new MessageService();
            config.Configurer.RegisterSingleton(typeof(IMessageService), _messageService);
        }
Пример #21
0
        public void When_a_handler_is_registered_for_a_specific_type_it_should_not_receive_other_events()
        {
            var aDomainEventEventHandler = MockRepository.GenerateMock<IEventHandler<ADomainEvent>>();

            var bus = new InProcessEventBus();
            bus.RegisterHandler(aDomainEventEventHandler);

            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());

            aDomainEventEventHandler.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Twice());
        }
Пример #22
0
        public void When_a_handler_is_registered_for_a_specific_type_it_should_not_receive_other_events()
        {
            var aDomainEventEventHandler = MockRepository.GenerateMock <IEventHandler <ADomainEvent> >();

            var bus = new InProcessEventBus();

            bus.RegisterHandler(aDomainEventEventHandler);

            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());

            aDomainEventEventHandler.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Twice());
        }
Пример #23
0
        public void When_multiple_messages_are_published_and_a_specific_handler_is_register_oply_the_matching_events_should_be_received_at_the_handler()
        {
            var aDomainEventHandler = MockRepository.GenerateMock<IEventHandler<ADomainEvent>>();
            var bus = new InProcessEventBus();
            bus.RegisterHandler(aDomainEventHandler);

            var events = new IPublishableEvent[]
                             {
                                 CreateAEvent(), CreateADomainEvent(), CreateADomainEvent(), CreateAEvent(), CreateADomainEvent(), CreateAEvent(),
                                 CreateAEvent(), CreateADomainEvent(), CreateADomainEvent(), CreateAEvent(), CreateADomainEvent(), CreateAEvent()
                             };

            bus.Publish(events);

            aDomainEventHandler.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(6));
        }
Пример #24
0
        private static IEventBus InitializeEventBus()
        {
            var bus = new InProcessEventBus();

            //bus.RegisterHandler(new SqlTweetIndexItemDenormalizer());
            bus.RegisterHandler(new FileTweetIndexItemDenormalizer());
            bus.RegisterHandler(new FileTweetIndexItemDeleteDenormalizer());
            bus.RegisterHandler(new ChannelIndexItemDenormalizer());
            bus.RegisterHandler(new UserIndexDenormalizer());
            bus.RegisterHandler(new UserIndexDeleteDenormalizer());
            bus.RegisterHandler(new UserIndexPropertySetDenormalizer());
            bus.RegisterHandler(new UserIndexPasswordSetDenormalizer());
            bus.RegisterHandler(new UserIndexValidatedDenormalizer());
            bus.RegisterHandler(new UserIndexInvalidatedDenormalizer());
            bus.RegisterHandler(new UserIndexAddedToRoleDenormalizer());
            bus.RegisterHandler(new UserIndexRemovedFromDenormalizer());

            return(bus);
        }
Пример #25
0
 /// <summary>
 /// Register a handler that will receive all messages that are published.
 /// </summary>
 /// <param name="handler">The handler to register.</param>
 public ConfigNcqrs RegisterInProcessEventHandler <TEvent>(IEventHandler <TEvent> handler) where TEvent : IEvent
 {
     _inProcessEventBus.RegisterHandler(handler);
     return(this);
 }
Пример #26
0
        public void When_a_multiple_specific_handlers_are_register_they_all_should_be_called_when_the_specific_event_is_published()
        {
            var specificEventHandler1 = MockRepository.GenerateMock<IEventHandler<ADomainEvent>>();
            var specificEventHandler2 = MockRepository.GenerateMock<IEventHandler<ADomainEvent>>();
            var specificEventHandler3 = MockRepository.GenerateMock<IEventHandler<ADomainEvent>>();

            var bus = new InProcessEventBus();
            bus.RegisterHandler(specificEventHandler1);
            bus.RegisterHandler(specificEventHandler2);
            bus.RegisterHandler(specificEventHandler3);

            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateADomainEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());
            bus.Publish(CreateAEvent());

            specificEventHandler1.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(2));
            specificEventHandler2.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(2));
            specificEventHandler3.AssertWasCalled(h => h.Handle(null), options => options.IgnoreArguments().Repeat.Times(2));
        }
Пример #27
0
 public void RegisterHandler<TEvent>(IEventHandler<TEvent> handler) where TEvent : IEvent
 {
     _internalBus.RegisterHandler(handler);
 }