public void CanParseExpressionWithEscapeRazorCharacter() { var template = @" @@ @@Test <span>@@@@</span> "; var result = RazorJs.Parse(template, new { ID = "Tester" }); Assert.IsTrue(result.Contains("@@")); }
public void CanParseExpressionWithEmail() { var template = @" @{ var value = 'World'; } <span>[email protected]</span> " ; var result = RazorJs.Parse(template); Assert.IsTrue(result.Contains("*****@*****.**")); }
public void CanParseExpressionWithDoubleRazorChar() { var template = @" @{ var value = 'World'; } <span>@@value</span> " ; var result = RazorJs.Parse(template); Assert.IsTrue(result.Contains("@value")); }
public void CanParseExpressionCommentAndIgnoreParsingofRazorInComment() { var template = @" @* @if(true){ <span>@test</span> } *@ "; var result = RazorJs.Parse(template, new { ID = "Tester" }); Assert.IsTrue(result.Contains("@if")); }
public void CannotParseInvalidRazorSyntax() { var template = @" @ Model.ID @{ var test = 'Test'; } "; Exception ex = null; try { RazorJs.Parse(template, new { ID = "Tester" }); } catch (Exception e) { ex = e; } Assert.IsNotNull(ex); }
public string GetRazorResult(string model, string razorTemplate) { var result = RazorJs.Parse(razorTemplate, model: model.TrimEnd('\n', '\r')); return(result); }
// // You can use the following additional attributes as you write your tests: // // Use ClassInitialize to run code before running the first test in the class // [ClassInitialize()] // public static void MyClassInitialize(TestContext testContext) { } // // Use ClassCleanup to run code after all tests in a class have run // [ClassCleanup()] // public static void MyClassCleanup() { } // // Use TestInitialize to run code before running each test // [TestInitialize()] // public void MyTestInitialize() { } // // Use TestCleanup to run code after each test has run // [TestCleanup()] // public void MyTestCleanup() { } // #endregion private static void TestTemplate(string template) { var result = RazorJs.Parse(template, new { ID = "Tester" }); Assert.IsTrue(!result.Contains("@")); }