public void TestParser(string input, MustacheExpression expected)
        {
            var underTest = new HandlebarsParser();
            var result = underTest.Parse(input);

            HandlebarsExpressionAssert.AssertExpression(expected, result);
        }
        public static void AssertExpression(MustacheExpression expected, MustacheExpression result)
        {
            if (expected == null)
                Assert.Null(result);

            var memberAccess = expected as MemberExpression;
            var conditional = expected as ConditionalExpression;
            var helper = expected as CallHelperExpression;
            var iteration = expected as IterationExpression;
            var html = expected as UnconvertedExpression;

            if (memberAccess != null)
            {
                Assert.IsType<MemberExpression>(result);
                AssertExpression(memberAccess, result as MemberExpression);
            }
            else if (conditional != null)
            {
                Assert.IsType<ConditionalExpression>(result);
                AssertExpression(conditional, result as ConditionalExpression);
            }
            else if (iteration != null)
            {
                Assert.IsType<IterationExpression>(result);
                AssertIterationExpression(iteration, (IterationExpression) result);
            }
            else if (helper != null)
            {
                Assert.IsType<CallHelperExpression>(result);
                AssertExpression(helper, result as CallHelperExpression);
            }
            else if (html != null)
            {
                Assert.IsType<UnconvertedExpression>(result);
                AssertExpression(html, result as UnconvertedExpression);
            }
            else
                Assert.False(true, "Unknown expression type.");
        }
Ejemplo n.º 3
0
 public Statement(MustacheExpression expression, params Node[] childNodes)
 {
     Expression = expression;
     ChildNodes = childNodes;
 }
Ejemplo n.º 4
0
 public AttributeStatement(MustacheExpression expression, params AttributeNode[] childNodes)
 {
     Expression = expression;
     ChildNodes = childNodes;
 }
 public AttributeContentStatement(MustacheExpression expression, params AttributeContent[] children)
 {
     Expression = expression;
     Children = children ?? new AttributeContent[0];
 }