public void TestBuilderWithSettings()
        {
            // Arrange
            PipelineComponentResolver.Add(new ConfigurableComponent());

            var pipeline = NonAsyncPipelineBuilder <TestPayload>
                           .Initialize(null)
                           .WithComponent <ConfigurableComponent>()
                           .WithComponentResolver(PipelineComponentResolver)
                           .WithSettings(new Dictionary <string, IDictionary <string, string> >
            {
                {
                    "ConfigurableComponent", new Dictionary <string, string>
                    {
                        { "UseFoo", "false" },
                        { "TestValue", "MyBarTestValue" }
                    }
                }
            })
                           .Build();

            var payload = new TestPayload();

            // Act
            var result = pipeline.Execute(payload);

            // Assert
            pipeline.Name.StartsWith("Pipeline").Should().BeTrue();
            payload.FooStatus.Should().BeNull();
            result.BarStatus.Should().Be("MyBarTestValue");
        }
        public void TestBuilderByComponentType()
        {
            // Arrange
            const string name = "test-name";

            PipelineComponentResolver.Add(new FooComponent());
            PipelineComponentResolver.Add(new BarComponent());

            var pipeline = NonAsyncPipelineBuilder <TestPayload>
                           .Initialize(null)
                           .WithComponent <FooComponent>()
                           .WithComponent <BarComponent>()
                           .WithComponentResolver(PipelineComponentResolver)
                           .WithoutSettings()
                           .Build(name);

            var payload = new TestPayload();

            // Act
            payload.FooWasCalled.Should().BeFalse();
            payload.BarWasCalled.Should().BeFalse();
            var result = pipeline.Execute(payload);

            // Assert
            pipeline.Name.Should().Be(name);
            result.Count.Should().Be(2);
            result.Count.Should().Be(2);
            result.FooWasCalled.Should().BeTrue();
            result.BarWasCalled.Should().BeTrue();
        }
        public void TestWithComponent_ThrowsInvalidOperationException()
        {
            // Arrange

            // Act
            Action act = () => NonAsyncPipelineBuilder <TestPayload>
                         .Initialize(null)
                         .WithComponent(typeof(string));


            // Assert
            act.Should()
            .ThrowExactly <InvalidOperationException>()
            .WithMessage("* does not derive from *");
        }
        public void TestBuilderWithSettings()
        {
            // Arrange
            var pipeline = NonAsyncPipelineBuilder <TestPayload>
                           .Initialize()
                           .WithComponent("Component1")
                           .WithComponent("Component2")
                           .WithComponentResolver(PipelineComponentResolver)
                           .WithSettings(new Dictionary <string, IDictionary <string, string> >
            {
                {
                    "Component1", new Dictionary <string, string>
                    {
                        { "UseFoo", "true" },
                        { "TestValue", "MyFooTestValue" }
                    }
                },
                {
                    "Component2", new Dictionary <string, string>
                    {
                        { "UseFoo", "false" },
                        { "TestValue", "MyBarTestValue" }
                    }
                }
            })
                           .Build();

            var payload = new TestPayload();

            // Act
            payload.FooStatus.Should().BeNull();
            payload.BarStatus.Should().BeNull();
            var result = pipeline.Execute(payload);

            // Assert
            result.FooStatus.Should().Be("MyFooTestValue");
            result.BarStatus.Should().Be("MyBarTestValue");
        }
        public void TestBuilderMixAndMatchComponents()
        {
            // Arrange
            var pipeline = NonAsyncPipelineBuilder <TestPayload>
                           .Initialize()
                           .WithComponent <FooComponent>()
                           .WithComponent("BarComponent")
                           .WithComponentResolver(PipelineComponentResolver)
                           .WithNoSettings()
                           .Build();

            var payload = new TestPayload();

            // Act
            payload.FooWasCalled.Should().BeFalse();
            payload.BarWasCalled.Should().BeFalse();
            var result = pipeline.Execute(payload);

            // Assert
            result.Count.Should().Be(2);
            result.FooWasCalled.Should().BeTrue();
            result.BarWasCalled.Should().BeTrue();
        }
Пример #6
0
 public static IInitialPipelineComponentHolder <IPipeline <TPayload>, IPipelineComponent <TPayload>, TPayload> NonAsync()
 {
     return(NonAsyncPipelineBuilder <TPayload> .Initialize());
 }