public async Task when_append_steps_into_pipeline_it_should_handle_message_expected_way()
        {
            var container = SetupContainer();
            var pipeline  = new Pipeline();
            var sut       = new VentureIngressPipeFitter(container.GetInstance <IDiContainerAdapter>());

            var context = CreateContext();

            await using (AsyncScopedLifestyle.BeginScope(container))
            {
                sut.AppendStepsInto(pipeline);
                await pipeline.Execute(context);
            }

            context.Message.Should()
            .BeOfType <Message1>()
            .Subject.IsExecuted.Should().BeTrue("message should be handled");
            context.Handlers.Should()
            .NotBeNull("message handler should be found and stored in the context").And
            .BeOfType <HandlerDescriptor[]>()
            .Subject.Single().HandlerType.Should().Be <Massage1Handler>("message handler should be of expected type");
            context.TypeName.Should().Be(nameof(Message1));
            context.CorrelationId.Should().Be("VentureApi.Headers.CorrelationId");
            context.CausationId.Should().Be("VentureApi.Headers.CausationId");
            context.MessageId.Should().Be("VentureApi.Headers.MessageId");
            context.MessageType.Should().Be(typeof(Message1));
            context.Api.Should().NotBeNull();
        }
        public async Task when_executed_without_context_it_should_fail()
        {
            var container  = SetupContainer();
            var pipeline   = new Pipeline();
            var pipeFitter = new VentureIngressPipeFitter(container.GetInstance <IDiContainerAdapter>());

            // ReSharper disable once AssignNullToNotNullAttribute - it's a test against null.
            // ReSharper disable once ObjectCreationAsStatement
            Func <Task> sut = () => pipeline.Execute(context: null);

            await using (AsyncScopedLifestyle.BeginScope(container))
            {
                pipeFitter.AppendStepsInto(pipeline);
                sut.Should().Throw <ArgumentNullException>("context is required");
            }
        }
        public void when_append_steps_into_pipeline_it_should_contain_expected_steps_in_expected_order()
        {
            var container = SetupContainer();
            var pipeline  = new Pipeline();
            var sut       = new VentureIngressPipeFitter(container.GetInstance <IDiContainerAdapter>());

            using (AsyncScopedLifestyle.BeginScope(container))
            {
                sut.AppendStepsInto(pipeline);
            }

            pipeline.Steps.Select(step => step.GetType()).Should().Equal(
                new[]
            {
                typeof(ExtractRelationMetadataStep),
                typeof(ExtractMessageTypeStep),
                typeof(ParseBrokerMessageStep),
                typeof(FindMessageHandlersStep),
                typeof(ExecuteMessageHandlersStep)
            },
                "it is all steps in proper order");
        }