using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Mustache.Test { [TestClass] public class HtmlFormatCompilerTester { [TestMethod] public void ShouldEscapeValueContainingHTMLCharacters() { HtmlFormatCompiler compiler = new HtmlFormatCompiler(); var generator = compiler.Compile("Hello, {{Name}}!!!"); string html = generator.Render(new { Name = "John \"The Man\" Standford" }); Assert.AreEqual("Hello, John "The Man" Standford!!!", html); } [TestMethod] public void ShouldIgnoreHTMLCharactersInsideTripleCurlyBraces() { HtmlFormatCompiler compiler = new HtmlFormatCompiler(); var generator = compiler.Compile("Hello, {{{Name}}}!!!"); string html = generator.Render(new { Name = "John \"The Man\" Standford" }); Assert.AreEqual("Hello, John \"The Man\" Standford!!!", html); } [TestMethod] public void ShouldNotTouchValueContainingSingleCurlyBraces() { HtmlFormatCompiler compiler = new HtmlFormatCompiler(); var generator = compiler.Compile("Bold statement!"); string html = generator.Render(new { Style = "b { color: red; }" }); Assert.AreEqual("Bold statement!", html); } [TestMethod] public void ShouldNotTouchValueContainingSingleCurlyBracesInsideTripleCurlyBraces() { HtmlFormatCompiler compiler = new HtmlFormatCompiler(); var generator = compiler.Compile("Bold statement!"); string html = generator.Render(new { Style = "b { color: red; }" }); Assert.AreEqual("Bold statement!", html); } } }