public void TestParseOfListBoxTag() { var model = new TagModel(new Hashtable()); HtmlHelper helper = GetHtmlHelper(); helper.ViewData.Add("name", new MultiSelectList(new[] { "a", "b", "c", "d" }, null, null, new[] { "a", "c" })); model.Page[Html.PAGE_MODEL_HTMLHELPER_INSTANCE] = helper; model.Model["name"] = "name"; model.Model["list"] = new MultiSelectList(new[] { "a", "b", "c", "d" }, null, null, new[] { "a", "c" }); ITag tag = CreateFactory().Parse( "<html:listBox name=\"${Model.name}\" selectList=\"${Model.list}\"/>"); Assert.That(tag.Evaluate(model), Is.EqualTo( "<select id=\"name\" multiple=\"multiple\" name=\"name\"><option>a</option>\r\n<option>b</option>\r\n<option>c</option>\r\n<option>d</option>\r\n</select>")); }
public void TestParseOfCheckBoxTagWithHtmlAttribute() { var model = new TagModel(new Hashtable()); model.Page[Html.PAGE_MODEL_HTMLHELPER_INSTANCE] = GetHtmlHelper(); model.Model["name"] = "name"; model.Model["value"] = "true"; model.Model["style"] = "nice"; ITag tag = CreateFactory().Parse( "<html:checkBox name=\"${Model.name}\" isChecked=\"${Model.value}\" class=\"${Model.style}\"/>"); Assert.That(tag.Evaluate(model), Is.EqualTo( "<input checked=\"checked\" class=\"nice\" id=\"name\" name=\"name\" type=\"checkbox\" value=\"true\" /><input name=\"name\" type=\"hidden\" value=\"false\" />" )); }
public void TestParseOfTextAreaTagWithHtmlAttribute() { var model = new TagModel(new Hashtable()); model.Page[Html.PAGE_MODEL_HTMLHELPER_INSTANCE] = GetHtmlHelper(); model.Model["name"] = "name"; model.Model["value"] = "true"; model.Model["style"] = "nice"; ITag tag = CreateFactory().Parse( "<html:textArea name=\"${Model.name}\" value=\"${Model.value}\" class=\"${Model.style}\"/>"); Assert.That(tag.Evaluate(model), Is.EqualTo( "<textarea class=\"nice\" cols=\"20\" id=\"name\" name=\"name\" rows=\"2\">\r\ntrue</textarea>")); }
public void TestParseOfRadioButtonTagWithHtmlAttribute() { var model = new TagModel(new Hashtable()); model.Page[Html.PAGE_MODEL_HTMLHELPER_INSTANCE] = GetHtmlHelper(); model.Model["name"] = "name"; model.Model["value"] = "true"; model.Model["style"] = "nice"; ITag tag = CreateFactory().Parse( "<html:radioButton name=\"${Model.name}\" value=\"${Model.value}\" class=\"${Model.style}\"/>"); //Console.WriteLine(tag.Evaluate(model).Replace("\"", "\\\"")); Assert.That(tag.Evaluate(model), Is.EqualTo("<input class=\"nice\" id=\"name\" name=\"name\" type=\"radio\" value=\"true\" />")); }
public void Tag_Scope_Should_Be_Handled_Correct() { var model = new Hashtable(); model.Add(VariableScope.Model.ToString(), new Hashtable()); var reflection = new TagModel(model); var list = new ArrayList(new[] { 1, 2, 3, 4, 5, 6 }); reflection["Model.list"] = list; reflection.PushTagStack(); reflection.Tag["last"] = "-"; ITag tag = Base().Parse( "<c:forEach items=\"${Model.list}\"><c:set value=\"${Item}\" var=\"last\"/></c:forEach>"); Assert.That(tag.Evaluate(reflection), Is.EqualTo(String.Empty)); Assert.That(reflection["Tag.last"], Is.EqualTo(6)); }
public void TestXmlForEach() { var model = new Hashtable(); var reflection = new TagModel(model); model.Add(VariableScope.Page.ToString(), new Hashtable()); string fileUrl = GetUrl("cd_catalog.xml"); Base().Parse("<c:import url='" + fileUrl + "' var='file'></c:import>").Evaluate(reflection); Base().Parse("<x:parse doc='${file}' var='fileAsXml'></x:parse>").Evaluate(reflection); ITag tag = Base().Parse( "<x:forEach source='fileAsXml' select='//CD'>[<x:out source='Item' select='./YEAR'/>]</x:forEach>"); Assert.That(tag.Evaluate(reflection), Is.EqualTo( "[1985][1988][1982][1990][1997][1998][1973][1990][1996][1987][1995][1999][1995][1997]")); }
public void TestXmlTransformFromFile() { var model = new Hashtable(); var reflection = new TagModel(model); model.Add(VariableScope.Page.ToString(), new Hashtable()); string fileUrl = GetUrl("cd_catalog.xml"); string fileUrl2 = GetUrl("cd_catalog.xsl"); Base().Parse("<c:import url='" + fileUrl + "' var='xmlFile'></c:import>").Evaluate(reflection); Base().Parse("<c:import url='" + fileUrl2 + "' var='xslFile'></c:import>").Evaluate(reflection); Base().Parse("<x:parse doc='${xmlFile}' var='xml'></x:parse>").Evaluate(reflection); Base().Parse("<x:parse doc='${xslFile}' var='xslt'></x:parse>").Evaluate(reflection); ITag tag = Base().Parse("<x:transform Doc='${xml}' Xslt='${xslt}'></x:transform>"); string result = File.ReadAllText("cd_catalog.html"); Assert.That(tag.Evaluate(reflection), Is.EqualTo(result)); }
public void TestParseOfTextAreaTag() { var model = new TagModel(new Hashtable()); model.Page[Html.PAGE_MODEL_HTMLHELPER_INSTANCE] = GetHtmlHelper(); model.Model["name"] = "name"; model.Model["value"] = "value"; model.Model["rows"] = "80"; model.Model["columns"] = "60"; model.Model["isChecked"] = "false"; ITag tag = CreateFactory().Parse( "<html:textArea name=\"${Model.name}\" value=\"${Model.value}\" columns=\"${Model.columns}\" rows=\"${Model.rows}\" isChecked=\"${Model.isChecked}\"/>"); Assert.That(tag.Evaluate(model), Is.EqualTo( "<textarea cols=\"60\" id=\"name\" isChecked=\"false\" name=\"name\" rows=\"80\">\r\nvalue</textarea>")); }
public object Evaluate(TagModel model) { try { return(_tag.Evaluate(model)); } catch (ExceptionWithContext ewc) { if (ewc.Context == null) { throw ExceptionWithContext.MakePartial(ewc).Decorate(_tag.Context); } throw; } catch (Exception e) { throw TagException.EvaluationError(e).Decorate(_tag.Context); } }
public void TestParseOfCapitalizedAttribute() { ITag tag = Base().Parse("<c:if Test=\"true\">XYZ</c:if>"); Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo("XYZ")); }
public void TestParseWithCamelCaseAttributeNames() { ITag tag = Base().Parse("<c:out escape-xml=\"true\"><c:out value=\"<br/>\"/></c:out>"); Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo("&lt;br/&gt;")); }
public void TestOfParseOfIfSimpleBodyTrue() { ITag tag = Base().Parse("<c:if test=\"true\">XYZ</c:if>"); Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo("XYZ")); }
public void TestOfParseOfIfSimpleBodyFalse() { ITag tag = Base().Parse("<c:if test=\"false\">XYZ</c:if>"); Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo(String.Empty)); }
public void TestOfParseOfIfComplexBody() { ITag tag = Base().Parse("<c:if test=\"true\"><c:out value=\"'bla'\"></c:out></c:if>"); Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo("'bla'")); }
public void CheckPassThroughOfContentParsed() { ITag tag = CreateFactory().Parse("<sharp:include file='SharpTags/a.htm'/>"); Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo("aa")); }
public void CheckPassThroughOfContentParsed() { ITag tag = CreateFactory().Parse("<sharp:scope>aa</sharp:scope>"); Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo("aa")); }