Ejemplo n.º 1
0
        public void Concat()
        {
            var part1 = new InputPipe <List <int> >("part1");
            var part2 = new InputPipe <int[]>("part2");
            var concatWithPipeline = part1.ConcatWith(part2);
            var collector          = concatWithPipeline.Collect();

            PipelineApprovals.Verify(concatWithPipeline);

            // begin-snippet: ConcatWith_inputs
            var concat = new List <int> {
                1, 2
            };
            var with = new[] { 3, 4 };
            // end-snippet

            // begin-snippet: ConcatWith_outputs
            var result = "[1, 2, 3, 4]";
            // end-snippet

            var manualConcatWith =
                // begin-snippet: ConcatWith_manual
                part1.JoinTo(part2).ProcessFunction(t => t.Item1.Concat(t.Item2).ToList());
            // end-snippet
            var manualConcatWithResult = manualConcatWith.Collect();

            part1.Send(concat);
            part2.Send(with);
            Assert.AreEqual(result, collector.SingleResult.ToReadableString());

            Assert.AreEqual(
                manualConcatWithResult.SingleResult.ToReadableString(),
                collector.SingleResult.ToReadableString());
        }
Ejemplo n.º 2
0
        public void ApplyTo()
        {
            var prefix = new InputPipe <string>("prefix");
            var values = new InputPipe <int[]>("values");

            var applyToPipeline = prefix.ApplyTo(values);
            var collector       = applyToPipeline.Collect();

            PipelineApprovals.Verify(applyToPipeline);

            // begin-snippet: ApplyTo_inputs
            var apply = "#";
            var to    = new[] { 1, 2 };
            // end-snippet

            // begin-snippet: ApplyTo_outputs
            var result = "[(#, 1), (#, 2)]";
            // end-snippet

            var manualApplyTo =
                // begin-snippet: ApplyTo_manual
                prefix.JoinTo(values).ProcessFunction(t => t.Item2.Select(i => Tuple.Create(t.Item1, i)));
            // end-snippet
            var manualApplyToResult = manualApplyTo.Collect();

            prefix.Send(apply);
            values.Send(to);
            Assert.AreEqual(result, collector.SingleResult.ToReadableString());

            Assert.AreEqual(
                manualApplyToResult.SingleResult.ToReadableString(),
                collector.SingleResult.ToReadableString());
        }
Ejemplo n.º 3
0
        public void SplitInput()
        {
            var input = new InputPipe <long>("value");

            input.ProcessFunction(LongToString);
            input.ProcessFunction(IncrementLong);

            PipelineApprovals.Verify(input);
        }
Ejemplo n.º 4
0
        public void Lambda()
        {
            // begin-snippet: process_lambda
            var input = new InputPipe <int>("input");

            input.Process(p => p.ToString());
            // end-snippet

            PipelineApprovals.Verify(input);
        }
Ejemplo n.º 5
0
        public void BasicPipelineTest()
        {
            var input     = new InputPipe <string>("age");
            var parse     = input.ProcessFunction(long.Parse);
            var collector = parse.Collect();

            PipelineApprovals.Verify(input);
            input.Send("42");
            Assert.AreEqual(42, collector.SingleResult);
        }
        public void Cast()
        {
            var input     = new InputPipe <Animal>("animal");
            var dog       = input.Cast <Dog>();
            var collector = dog.Process(d => d.IsGoodBoy).Collect();

            input.Send(new Dog());
            Assert.IsTrue(collector.SingleResult);
            PipelineApprovals.Verify(input);
        }
        public void SplitInput()
        {
            // begin-snippet: graphviz_approval
            var input = new InputPipe <long>("value");

            input.ProcessFunction(LongToString);
            input.ProcessFunction(IncrementLong);

            PipelineApprovals.Verify(input);
            // end-snippet
        }
Ejemplo n.º 8
0
        public void JoinInputsSample()
        {
            // begin-snippet: joined_pipeline
            var input1 = new InputPipe <long>("value1");
            var input2 = new InputPipe <long>("value2");
            var join   = input1.JoinTo(input2);

            // end-snippet

            PipelineApprovals.Verify(join);
        }
Ejemplo n.º 9
0
        public void SplitAndJoin()
        {
            var input         = new InputPipe <string>("age");
            var parse         = input.ProcessFunction(long.Parse);
            var longToString  = parse.ProcessFunction(LongToString);
            var incrementLong = parse.ProcessFunction(IncrementLong);

            var joinedPipes = longToString.JoinTo(incrementLong).Collect();

            PipelineApprovals.Verify(input);
        }
Ejemplo n.º 10
0
        public void ForEach()
        {
            var part1     = new InputPipe <List <long> >("part1");
            var collector = part1.ProcessForEach(IncrementLong).Collect();

            part1.Send(new List <long> {
                1, 2
            });
            Assert.AreEqual("[2, 3]", collector.SingleResult.ToReadableString());

            PipelineApprovals.Verify(part1);
        }
Ejemplo n.º 11
0
        public void JoinInputs()
        {
            var input1    = new InputPipe <long>("value1");
            var input2    = new InputPipe <long>("value2");
            var join      = input1.JoinTo(input2);
            var collector = join.ProcessFunction(Echo).Collect();

            input1.Send(42);
            Assert.IsTrue(collector.IsEmpty);

            input2.Send(99);
            Assert.AreEqual("(42, 99)", collector.SingleResult.ToString());

            PipelineApprovals.Verify(join);
        }
Ejemplo n.º 12
0
        public void MultipleParameters()
        {
            var input1    = new InputPipe <long>("value1");
            var input2    = new InputPipe <long>("value2");
            var join      = input1.JoinTo(input2);
            var collector = join.Process((a, b) => a + b).Collect();

            input1.Send(3);
            Assert.IsTrue(collector.IsEmpty);

            input2.Send(4);
            Assert.AreEqual(7, collector.SingleResult);

            PipelineApprovals.Verify(join);
        }
Ejemplo n.º 13
0
        public void ConnectedPipelinesTest()
        {
            var input     = new InputPipe <string>("age");
            var parsePipe = input.ProcessFunction(long.Parse);
            var collector = parsePipe.Collect();

            parsePipe.ProcessFunction(LongToString)
            .WithCollector()
            .ProcessFunction(long.Parse)
            .WithCollector()
            .ProcessFunction(LongToString)
            .Collect();

            PipelineApprovals.Verify(input);
        }
    public static string Convert(int i)
    {
        // Set up Pipeline
        var inputpipe           = new InputPipe <int>("number");
        var pipe                = inputpipe.Process(_ => _.ToString());
        var methodCallCollector = pipe.Collect();

        inputpipe.Send(i);
        var variable = methodCallCollector.SingleResult;

        // ApprovalPipeline
        PipelineApprovals.Verify(inputpipe);
        // Send thru pipeline
        // Original code
        return(i.ToString());
    }
Ejemplo n.º 15
0
        public void Flatten()
        {
            var input1 = new InputPipe <long>("value1");
            var input2 = new InputPipe <long>("value2");
            var join   = input1.JoinTo(input2);
            var input3 = new InputPipe <long>("value3");

            Sender <Tuple <long, long, long> > all = join.JoinTo(input3).Flatten();
            var collector = all.Collect();

            input1.Send(1);
            input2.Send(2);
            input3.Send(3);

            Assert.AreEqual("(1, 2, 3)", collector.SingleResult.ToString());

            PipelineApprovals.Verify(collector);
        }
Ejemplo n.º 16
0
        public void ParallelRuns()
        {
            var inputPipe    = new InputPipe <ConcurrentBag <int> >("inputs");
            var echoPipe     = inputPipe.Process(_ => _);
            var listAddPipe1 = echoPipe.Process(l => AddToList(l, 1));
            var listAddPipe2 = echoPipe.Process(l => AddToList(l, 2));
            var listAddPipe3 = echoPipe.Process(l => AddToList(l, 3));
            var listAddPipe4 = echoPipe.Process(l => AddToList(l, 4));
            var listAddPipe5 = echoPipe.Process(l => AddToList(l, 5));
            var listAddPipe6 = echoPipe.Process(l => AddToList(l, 6));
            var listAddPipe7 = echoPipe.Process(l => AddToList(l, 7));

            var joinedPipe = listAddPipe1.JoinTo(listAddPipe2);

            var list1 = new ConcurrentBag <int>();
            var list2 = new ConcurrentBag <int>();

            inputPipe.Send(list1);
            inputPipe.Send(list2);
            Assert.AreEqual(list1.OrderBy(_ => _).ToReadableString(), list2.OrderBy(_ => _).ToReadableString());

            PipelineApprovals.Verify(inputPipe);
        }
Ejemplo n.º 17
0
 public void TestPipeline()
 {
     PipelineApprovals.Verify(CreatePipeline());
 }
Ejemplo n.º 18
0
        public void FizzBuzzPipeline()
        {
            var fizzBuzzPipeline = CreateFizzBuzzPipeline();

            PipelineApprovals.Verify(fizzBuzzPipeline);
        }
 public void CreatePipeline()
 {
     PipelineApprovals.Verify(Pipeline.Create().Collector);
 }