Exemple #1
0
        public void TestObjectDecorationValueEvaluator(string value, string expected)
        {
            var    tree   = ObjectDecorationParserFacade.ParseObjectDecorationValue(value);
            string actual = (string)_evaluator.Visit(tree, null);

            Assert.Equal(expected, actual);
        }
Exemple #2
0
        public void TestSimpleExpression()
        {
            var parseTree = ObjectDecorationParserFacade.ParseObjectDecorationValue(SIMPLE_EXPRESSION);

            Assert.Equal(3, parseTree.List.Count);
            Assert.IsType <LiteralNode>(parseTree.List[0]);
            Assert.IsType <LiteralNode>(parseTree.List[2]);

            var invocationExpression = (InvocationNode)parseTree.List[1];

            Assert.Equal("regex_extract", invocationExpression.FunctionName.Identifier);
            Assert.Equal(2, invocationExpression.Arguments.Count);
            Assert.IsType <IdentifierNode>(invocationExpression.Arguments[0]);
            Assert.IsType <LiteralNode>(invocationExpression.Arguments[1]);
        }
Exemple #3
0
        public void TestNestedExpression()
        {
            var parseTree = ObjectDecorationParserFacade.ParseObjectDecorationValue(NESTED_EXPRESSION);

            Assert.Single(parseTree.List);

            var invocationExpression = (InvocationNode)parseTree.List[0];

            Assert.Equal("substr", invocationExpression.FunctionName.Identifier);
            Assert.Equal(2, invocationExpression.Arguments.Count);
            var arg0 = (InvocationNode)invocationExpression.Arguments[0];

            Assert.Equal("regex_extract", arg0.FunctionName.Identifier);
            Assert.Equal(2, arg0.Arguments.Count);
            Assert.IsType <IdentifierNode>(arg0.Arguments[0]);
            Assert.IsType <LiteralNode>(arg0.Arguments[1]);

            Assert.IsType <LiteralNode>(invocationExpression.Arguments[1]);
        }