コード例 #1
0
        public void TestExpression(Dictionary <string, object> context, string expression, object expectedResult)
        {
            var questions = new List <Questionnaires.RunTime.Question>();

            foreach (var value in context)
            {
                questions.Add(ValueCreator.CreateQuestion(value.Key, (dynamic)value.Value));
            }

            var store = new QuestionStore(questions);

            var astFactory = new ASTBuilder(new Result());
            var AST        = astFactory.BuildExpression(expression);

            var evaluator = new Questionnaires.RunTime.ExpressionEvaluator(store);
            var result    = evaluator.Evaluate((IExpression)AST);

            Value.ValueTester.Test((dynamic)result, expectedResult);
        }