public void AggregateWhenNoExpressionThenThrowsException() { var expressions = new List<IExpression<string, int>>(); const int Parameter = 7; var context = new Context(); Action action = () => this.testee.Aggregate(expressions, Parameter, context); action.ShouldThrow<InvalidOperationException>(); }
public void FoundAnswer(Context context) { var expressions = from expression in context.Expressions select new { Expression = expression.Expression.Describe(), expression.ExpressionResult }; this.FoundAnswerLog = string.Format( "Question = {1}{0}Strategy = {2}{0}Aggregator = {3}{0}Parameter = {4}{0}Answer = {5}{0}Expressions = {6}", Environment.NewLine, context.Question.Describe(), context.Strategy.Describe(), context.Aggregator.Describe(), context.Parameter, context.Answer, expressions.Aggregate(string.Empty, (aggregate, value) => aggregate + Environment.NewLine + " " + value.Expression + " returned " + value.ExpressionResult)); }
/// <summary> /// Logs the found answer together with information how it was found. /// </summary> /// <param name="context">The context.</param> public void FoundAnswer(Context context) { var expressions = from expression in context.Expressions select string.Format(CultureInfo.InvariantCulture, "{0} => {1}", expression.Expression.Describe(), expression.ExpressionResult); string format = context.Parameter == Missing.Value ? "Question = {1}{0}Answer = {3}{0}Used strategy = {4}{0}Used Aggregator = {5}{0}Expressions = {6}" : "Question = {1}{0}Parameter = {2}{0}Answer = {3}{0}Used strategy = {4}{0}Used Aggregator = {5}{0}Expressions = {6}"; string message = string.Format( CultureInfo.InvariantCulture, format, Environment.NewLine, context.Question.Describe(), context.Parameter, context.Answer, context.Strategy.Describe(), context.Aggregator.Describe(), expressions.Aggregate(string.Empty, (aggregate, value) => aggregate + Environment.NewLine + " " + value)); this.log.Info(message); }
/// <summary> /// Logs the found answer together with information how it was found. /// </summary> /// <param name="context">The context.</param> public void FoundAnswer(Context context) { }