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); }
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); }
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); }
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 ")); }
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 ")); }