public void DynamicNonNativeTypeOnlyParameterPassing() { string template = "A line with @model.Str and @model2.I with @@ignore me"; Model model = new Model() { Str = "I'm Dynamic!", I=20 }; Model2 model2 = new Model2() { I = 20 }; TemplateEngine eng = new TemplateEngine(); eng.UsesDynamic(); string ret = eng.Parse(template, model, model2); Assert.AreEqual("A line with I'm Dynamic! and 20 with @ignore me\r\n", ret); }
public void CacheTest() { string template = "A line with @model.Str and @model2.I with @@ignore me"; Model model = new Model() { Str = "I'm Dynamic!", I = 20 }; Model2 model2 = new Model2() { I = 20 }; TemplateEngine eng = new TemplateEngine(); eng.UsesDynamic(); string ret = eng.Parse(template, model, model2); Assert.AreEqual("A line with I'm Dynamic! and 20 with @ignore me\r\n", ret); Assert.IsTrue(eng.IsCached(template)); model.Str = "Cached!"; model2.I = 25; ret = eng.Parse(template, model, model2); Assert.AreEqual("A line with Cached! and 25 with @ignore me\r\n", ret); }
protected void InitializeTemplateEngine() { templateEngine = new TemplateEngine(ServiceManager.Get<ISemanticProcessor>()); templateEngine.UsesDynamic(); }
public void VarReplacementInLiteral() { string template = @" @{ @:alert(""<@model.Str@>"") }"; Model model = new Model() { Str = "Welcome!" }; TemplateEngine eng = new TemplateEngine(); eng.UsesDynamic(); string ret = eng.Parse(template, model); Assert.AreEqual("alert(\"\" + model.Str.ToString() + \"\r\n", ret); }