Esempio n. 1
0
 public BusMiddleWare()
 {
     _internalMiddleware = new Middleware <T>();
     _internalMiddleware.Add <TestAction1 <T> >();
     _internalMiddleware.Add <TestGenericAction <T> >();
     _internalMiddleware.Add <ConsumerAction <T> >();
 }
Esempio n. 2
0
 public void BeforeNotify(Middleware middleware)
 {
     lock (MiddlewareLock)
     {
         Middleware.Add(middleware);
     }
 }
        public MessagePublishContextMiddleware(PublishContextActions actions)
        {
            _internalMiddleware = new Middleware <MessagePublishContext <T> >();

            //if (actions.LoggingAction != null) _internalMiddleware.Add(actions.LoggingAction);
            if (actions.ApmAction != null)
            {
                _internalMiddleware.Add(MakeGeneric <T>(actions.ApmAction));
            }
            if (actions.PrepareMessageContextForPublish != null)
            {
                _internalMiddleware.Add(MakeGeneric <T>(actions.PrepareMessageContextForPublish));
            }

            foreach (var customAction in actions.CustomActions)
            {
                _internalMiddleware.Add(MakeGeneric <T>(customAction));
            }

            _internalMiddleware.Add(MakeGeneric <T>(actions.InvokePublisherAction));
        }
Esempio n. 4
0
        public ReceivedMessageMiddleware(ReceivedContextActions actions)
        {
            _internalMiddleware = new Middleware <MessageReceivedContext <T> >();

            _internalMiddleware.Add(MakeGeneric <T>(actions.ReadMessageFromQueueIntoContextAction));
            if (actions.LoggingAction != null)
            {
                _internalMiddleware.Add(MakeGeneric <T>(actions.LoggingAction));
            }
            if (actions.ApmAction != null)
            {
                _internalMiddleware.Add(MakeGeneric <T>(actions.ApmAction));
            }
            if (actions.DeadLetterAction != null)
            {
                _internalMiddleware.Add(MakeGeneric <T>(actions.DeadLetterAction));
            }

            foreach (var customAction in actions.CustomActions)
            {
                _internalMiddleware.Add(MakeGeneric <T>(customAction));
            }

            _internalMiddleware.Add(MakeGeneric <T>(actions.InvokeConsumerAction));
        }
        public async Task RunPreMiddleware_should_run_middleware_when_one_middleware()
        {
            // Arrange
            var middleware = BuildWorkflowMiddleware(WorkflowMiddlewarePhase.PreWorkflow);

            Middleware.Add(middleware);

            // Act
            await Runner.RunPreMiddleware(Workflow, Definition);

            // Assert
            A
            .CallTo(HandleMethodFor(middleware))
            .MustHaveHappenedOnceExactly();
        }
Esempio n. 6
0
        public async Task ExecuteStep_should_run_middleware_and_step_when_one_middleware()
        {
            // Arrange
            var middleware = BuildStepMiddleware();

            Middleware.Add(middleware);

            // Act
            var result = await Runner.ExecuteStep(Context, Body);

            // Assert
            result.Should().Be(DummyResult);
            A
            .CallTo(RunMethodFor(Body))
            .MustHaveHappenedOnceExactly()
            .Then(
                A.CallTo(HandleMethodFor(middleware))
                .MustHaveHappenedOnceExactly());
        }