Ejemplo n.º 1
0
        public void BangSyntaxHasRawContentWhenDisabled()
        {
            var settings = new ParserSettings { AutomaticEncoding = false };
            var grammar = new MarkupGrammar(settings);
            var result = grammar.Nodes(Source("!{'hello world'}"));

            Assert.AreEqual(1, result.Value.Count);
            Assert.AreEqual("\"hello world\"", (string)((ExpressionNode)result.Value[0]).Code);
            Assert.IsFalse(((ExpressionNode)result.Value[0]).AutomaticEncoding);
        }
Ejemplo n.º 2
0
        public void HashSyntaxIgnoredWhenCustomMarkerProvided()
        {
            var settings = new ParserSettings { AutomaticEncoding = true, StatementMarker = "hi" };
            var grammar = new MarkupGrammar(settings);
            var result = grammar.Nodes(Source("  #foo  \r\n"));

            Assert.AreEqual(1, result.Value.Count);
            var statement = result.Value.OfType<StatementNode>().Any();
            Assert.That(statement, Is.False);
        }
Ejemplo n.º 3
0
        public void DollarHasEncodedContentWhenEnabled()
        {
            var settings = new ParserSettings { AutomaticEncoding = true };
            var grammar = new MarkupGrammar(settings);
            var result = grammar.Nodes(Source("${'hello world'}"));

            Assert.AreEqual(1, result.Value.Count);
            Assert.AreEqual("\"hello world\"", (string)((ExpressionNode)result.Value[0]).Code);
            Assert.IsTrue(((ExpressionNode)result.Value[0]).AutomaticEncoding);
        }
Ejemplo n.º 4
0
        public void HashSyntaxForStatementsByDefault()
        {
            var settings = new ParserSettings { AutomaticEncoding = true };
            var grammar = new MarkupGrammar(settings);
            var result = grammar.Nodes(Source("  #foo  \r\n"));

            Assert.AreEqual(2, result.Value.Count);
            var statement = result.Value.OfType<StatementNode>().Single();
            Assert.That(statement.Code.ToString(), Is.EqualTo("foo  "));
        }
Ejemplo n.º 5
0
        public void CustomMarkerForStatements()
        {
            var settings = new ParserSettings { AutomaticEncoding = true, StatementMarker="hi" };
            var grammar = new MarkupGrammar(settings);
            var result = grammar.Nodes(Source("  hibernate  \r\n"));

            Assert.AreEqual(2, result.Value.Count);
            var statement = result.Value.OfType<StatementNode>().Single();
            Assert.That(statement.Code.ToString(), Is.EqualTo("bernate  "));
        }