Beispiel #1
0
        public void setup_pipe_line_with_null_expect_null_return()
        {
            var context = new MathPipeContext(initialValue: 20);

            var masterPipe = new AdditionPipe()
                             .ExtendWith(new SubtractionPipe());

            for (int i = 0; i <= 1; i++)
            {
                if (i == 0)
                {
                    Assert.IsNotNull(masterPipe.NextPipe);
                }
                else
                {
                    Assert.IsNull(masterPipe.NextPipe);
                }
            }
        }
Beispiel #2
0
        // 20 + 1 = 21:
        // 21 -1 - 1 - 1 = 18
        // 18 + 1 + 1 + 1 = 21
        // 21 * 2 = 42
        // 42 - 1 = 41
        public void generate_a_tree_based_pipeline_expect_proper_execution()
        {
            var context = new MathPipeContext(initialValue: 20);

            var masterPipe = new AdditionPipe()
                             .ExtendWith(
                new SubtractionPipe()
                .ExtendWith(new SubtractionPipe())
                .ExtendWith(new SubtractionPipe())
                )
                             .ExtendWith(
                new AdditionPipe()
                .ExtendWith(new AdditionPipe())
                .ExtendWith(
                    new AdditionPipe()
                    .ExtendWith(new MultiplicationPipe())
                    )
                )
                             .ExtendWith(new SubtractionPipe());

            masterPipe.Process(context);

            Assert.AreEqual(41, context.Result);
        }