public void GetResult_return_empty_string() { var model = new Model(null); var templateEvaluator = new TemplateEvaluator(model); string result = templateEvaluator.GetResult(); Assert.IsEmpty(result); }
public void EvalText_GetResult_return_text() { var model = new Model(null); var templateEvaluator = new TemplateEvaluator(model); var element = new TextTemplateElement("123"); templateEvaluator.EvalText(element); string result = templateEvaluator.GetResult(); Assert.AreEqual("123", result); }
public void EvalMethod_GetResult_return_result_of_method() { var model = new ModelWithMethod(null, "123"); var evaluator = new TemplateEvaluator(model); var element = new MethodCallTemplateElement { MethodName = "GetText" }; evaluator.EvalMethod(element); Assert.AreEqual("123", evaluator.GetResult()); }
public static string Eval(string template, Model model) { var parser = new Parser(); TemplateModel templateModel = parser.Parse(template); var evaluator = new TemplateEvaluator(model); foreach (TemplateElement element in templateModel.Elements) { element.Accept(evaluator); } return(evaluator.GetResult()); }
public void EvalOutputValue_GetResult_return_property_value_as_string() { var model = new Model(new { Count = 5 }); var templateEvaluator = new TemplateEvaluator(model); var element = new OutputValueTemplateElement { ValueAccess = new PropertyValueAccess { Name = "Count" } }; templateEvaluator.EvalOutputValue(element); string result = templateEvaluator.GetResult(); Assert.AreEqual("5", result); }