public async Task TestBuilderWithSettings()
        {
            // Arrange
            PipelineComponentResolver.AddAsync(new ConfigurableComponent());

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

            var payload = new TestPayload();

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

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

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

            var pipeline = AsyncPipelineBuilder <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 = await pipeline.ExecuteAsync(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 async Task TestBuilderWithSettings()
        {
            // Arrange
            var pipeline = AsyncPipelineBuilder <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 = await pipeline.ExecuteAsync(payload);

            // Assert
            result.FooStatus.Should().Be("MyFooTestValue");
            result.BarStatus.Should().Be("MyBarTestValue");
        }
        public async Task TestBuilderMixAndMatchComponents()
        {
            // Arrange
            var pipeline = AsyncPipelineBuilder <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 = await pipeline.ExecuteAsync(payload);

            // Assert
            result.Count.Should().Be(2);
            result.FooWasCalled.Should().BeTrue();
            result.BarWasCalled.Should().BeTrue();
        }
Exemplo n.º 5
0
 public static IInitialPipelineComponentHolder <IAsyncPipeline <TPayload>, IAsyncPipelineComponent <TPayload>, TPayload> Async()
 {
     return(AsyncPipelineBuilder <TPayload> .Initialize());
 }