コード例 #1
0
        public void ProcessWithNoProcessors()
        {
            var pipeline = new InternalPipeline <int>(new Func <int, int>[] { });
            var output   = pipeline.Process(1);

            output.Should().Be(1);
        }
コード例 #2
0
        public void ProcessWithTwoProcessors()
        {
            int input = 2;

            var pipeline = new InternalPipeline <int>(new PipelineStep <int>(x => x + 1), new PipelineStep <int>(x => x * 2));

            var output = pipeline.Process(input);

            output.Should().Be(6);
        }
コード例 #3
0
        public void ProcessInParallel()
        {
            var pipeline = new InternalPipeline <int>(new PipelineStep <int>(x => x + 1), new PipelineStep <int>(x => x * 2));

            var output = Enumerable.Range(0, 10).AsParallel().Select(i => new { Input = i, Result = pipeline.Process(i) }).ToArray();

            foreach (var item in output)
            {
                item.Result.Should().Be((item.Input + 1) * 2);
            }
        }