public void NonLiteralAttribute() { // The template const string templ = "<p class=\"@Environment.Version\"/>"; string expected = "<p class=\"" + Environment.Version.ToString() + "\"/>"; // Arrange MicroRazorCompiler compiler = MicroRazorCompiler.CreateCSharp(); compiler.Host.NamespaceImports.Add("System"); // Act var results = compiler.Compile(templ); Assert.True(results.Success); Assert.Equal(expected, results.Compiled.Run()); }
public void ConditionalAttribute() { // The template const string templ = "@{object f = null;}<p class=\"foo @f bar\" />"; string expected = "<p class=\"foo bar\" />"; // Arrange MicroRazorCompiler compiler = MicroRazorCompiler.CreateCSharp(); compiler.Host.NamespaceImports.Add("System"); // Act var results = compiler.Compile(templ); Assert.True(results.Success); Assert.Equal(expected, results.Compiled.Run()); }
public void HtmlEncoding() { // The template const string templ = "<p>@(\"<p>\")</p>"; string expected = "<p><p></p>"; // Arrange MicroRazorCompiler compiler = MicroRazorCompiler.CreateCSharp(); compiler.Host.NamespaceImports.Add("System"); // Act var results = compiler.Compile(templ); Assert.True(results.Success); Assert.Equal(expected, results.Compiled.Run()); }