コード例 #1
0
        public void DescribesItselfWithSeedAndAggregationFunction()
        {
            const string Seed = "seed";
            Expression <Func <string, string, string> > aggregateFunc = (aggregate, value) => aggregate + value;

            var testee = new ExpressionAggregator <string, string>(Seed, aggregateFunc);

            string description = testee.Describe();

            description.Should().Be("expression aggregator with seed 'seed' and aggregate function (aggregate, value) => (aggregate + value)");
        }
コード例 #2
0
        public void AggregatesResultsOfEvaluatedExpressionsWithSpecifiedAggregationFunction()
        {
            const string Seed = "";

            var expressions = new IExpression <int, int>[]
            {
                new TestExpression {
                    Value = 1
                },
                new TestExpression {
                    Value = 2
                }
            };

            var testee = new ExpressionAggregator <int, string, int>(Seed, (sum, expressionResult) => sum + expressionResult);

            var answer = testee.Aggregate(expressions, 5, new Context());

            answer.Should().Be("67");
        }