public void GivenBuffer_ApplyTransformAndTwoSubpiplines_ShouldPass()
        {
            const int max    = 1000;
            const int offset = 10000;
            var       list   = new List <int>();
            var       list2  = new List <int>();

            var s1         = new List <int>();
            var s1Pipeline = new PipelineBlock <int>().DoAction(x => s1.Add(x));

            var s2         = new List <int>();
            var s2Pipeline = new PipelineBlock <int>().DoAction(x => s2.Add(x));

            var jobs = new PipelineBlock <int>()
                       .Register(s1Pipeline)
                       .Register(s2Pipeline)
                       .Select(x => x + 5)
                       .Broadcast()
                       .DoAction(x => list.Add(x))
                       .DoAction(x => list2.Add(x + offset))
                       .DoAction(x => s1Pipeline.Post(x))
                       .DoAction(x => s2Pipeline.Post(x));

            Enumerable.Range(0, max)
            .ForEach(async x => await jobs.Send(x));

            jobs.CompleteAndWait().Wait();

            list.Count.Should().Be(max);
            list2.Count.Should().Be(max);
            s1.Count.Should().Be(max);
            s2.Count.Should().Be(max);

            list
            .Select((x, i) => new { x, i })
            .All(x => x.x == x.i + 5)
            .Should().BeTrue();

            list2
            .Select((x, i) => new { i, x })
            .All(x => x.i + offset + 5 == x.x)
            .Should().BeTrue();

            s1
            .Select((x, i) => new { x, i })
            .All(x => x.x == x.i + 5)
            .Should().BeTrue();

            s2
            .Select((x, i) => new { x, i })
            .All(x => x.x == x.i + 5)
            .Should().BeTrue();
        }
        public void GivenRegisteredPipeline_WhenCompleteAndWait_ShouldProcessAllMessage()
        {
            const int postValue = 100;

            var s1         = new List <int>();
            var s1Pipeline = new PipelineBlock <int>().DoAction(x => s1.Add(x));

            var job = new PipelineBlock <int>()
                      .Register(s1Pipeline)
                      .DoAction(x => s1Pipeline.Post(x));

            job.Post(postValue);

            job.CompleteAndWait().Wait();

            s1.Count.Should().Be(1);
            s1[0].Should().Be(postValue);
        }