Exemplo n.º 1
0
        public void CreateShouldReturnBuilder()
        {
            // Act.
            var config = EventProcessorBuilder.Create();

            // Assert.
            Assert.NotNull(config);
        }
Exemplo n.º 2
0
        public void BuildShouldCreateProcessor()
        {
            // Act.
            var processor = EventProcessorBuilder.Create()
                            .Build();

            // Assert.
            Assert.NotNull(processor);
        }
Exemplo n.º 3
0
        public void RegisterEventHandlerShouldAllowMultipleHandlersForTheSameMessage()
        {
            // Arrange.
            var config   = EventProcessorBuilder.Create();
            var receiver = A.Fake <IMessagePump>();

            // Act.
            config.RegisterEventHandler <OrderRemovedEventHandler>(receiver);
            config.RegisterEventHandler <OrderRemovedEventHandler>(receiver);

            // Assert.
            Assert.Equal(2, config.Receivers[receiver].HandlerTypes[typeof(OrderCancelledEvent)].Count);
            Assert.Equal(2, config.Receivers[receiver].HandlerTypes[typeof(OrderDeletedEvent)].Count);
        }
Exemplo n.º 4
0
        public void RegisterEventHandlerShouldRegisterHandlerForSessions()
        {
            // Arrange.
            var config   = EventProcessorBuilder.Create();
            var receiver = A.Fake <ISessionMessagePump>();

            // Act.
            config.RegisterEventHandler <OrderRemovedEventHandler>(receiver);

            // Assert.
            Assert.True(config.Receivers.ContainsKey(receiver));
            Assert.Equal(2, config.Receivers[receiver].HandlerTypes.Count);
            Assert.True(config.Receivers[receiver].HandlerTypes[typeof(OrderDeletedEvent)][0] == typeof(OrderRemovedEventHandler));
            Assert.True(config.Receivers[receiver].HandlerTypes[typeof(OrderCancelledEvent)][0] == typeof(OrderRemovedEventHandler));
        }
Exemplo n.º 5
0
        public void GetReceiversShouldReturnEmptyIfNothingFound()
        {
            // Arrange.
            var receiver = A.Fake <IMessagePump>();
            var config   = EventProcessorBuilder.Create().RegisterEventHandlers(receiver, new[]
            {
                typeof(OrderConfirmedEventHandler)
            });

            // Act.
            var Receivers = config.GetHandlerTypes(receiver, typeof(OrderCancelledEvent));

            // Assert.
            Assert.True(config.Receivers.ContainsKey(receiver));
            Assert.Equal(0, Receivers.Count);
        }
Exemplo n.º 6
0
        public void RegisterEventHandlersShouldRegisterFluent()
        {
            // Arrange.
            var config   = EventProcessorBuilder.Create();
            var receiver = A.Fake <IMessagePump>();

            // Act.
            config = config.RegisterEventHandlers(receiver, cfg =>
                                                  cfg.With <OrderRemovedEventHandler>()
                                                  .With <OrderConfirmedEventHandler>());

            // Assert.
            Assert.True(config.Receivers.ContainsKey(receiver));
            Assert.Equal(3, config.Receivers[receiver].HandlerTypes.Count);
            Assert.True(config.Receivers[receiver].HandlerTypes[typeof(OrderDeletedEvent)][0] == typeof(OrderRemovedEventHandler));
            Assert.True(config.Receivers[receiver].HandlerTypes[typeof(OrderCancelledEvent)][0] == typeof(OrderRemovedEventHandler));
            Assert.True(config.Receivers[receiver].HandlerTypes[typeof(OrderConfirmedEvent)][0] == typeof(OrderConfirmedEventHandler));
        }