public void render_a_single_class_even_though_it_is_registered_more_than_once() { HtmlTag tag = new HtmlTag("div").Text("text"); tag.AddClass("a"); tag.ToCompacted().ShouldEqual("<div class=\"a\">text</div>"); tag.AddClass("a"); tag.ToCompacted().ShouldEqual("<div class=\"a\">text</div>"); }
public void is_visible_set_to_true_by_default() { var tag = new HtmlTag("div"); tag.Visible().ShouldBeTrue(); tag.ToCompacted().ShouldEqual("<div></div>"); }
public void insert_before() { var tag = new HtmlTag("div"); tag.Add("span"); tag.InsertFirst(new HtmlTag("p")); tag.ToCompacted().ShouldEqual("<div><p></p><span></span></div>"); }
public void render_metadata() { HtmlTag tag = new HtmlTag("div").Text("text"); tag.MetaData("a", 1); tag.MetaData("b", "b-value"); tag.ToCompacted().ShouldEqual("<div class=\"{'a':1,'b':'b-value'}\">text</div>"); // now with another class tag.AddClass("class1"); tag.ToCompacted().ShouldEqual("<div class=\"class1 {'a':1,'b':'b-value'}\">text</div>"); }
public void render_id() { HtmlTag tag = new HtmlTag("div").Id("theDiv"); tag.ToCompacted().ShouldEqual("<div id=\"theDiv\"></div>"); }
public void render_a_single_attribute() { HtmlTag tag = new HtmlTag("table").Attr("cellPadding", 2); tag.ToCompacted().ShouldEqual("<table cellPadding=\"2\"></table>"); }
public void prepend() { HtmlTag tag = new HtmlTag("div").Text("something"); tag.Prepend("more in front "); tag.ToCompacted().ShouldEqual("<div>more in front something</div>"); }
public void the_inner_text_is_html_encoded() { var tag = new HtmlTag("div"); tag.Text("<b>Hi</b>"); tag.ToCompacted().ShouldEqual("<div><b>Hi</b></div>"); }
public void render_tag_with_one_child() { HtmlTag tag = new HtmlTag("div").Child(new HtmlTag("span").Text("something")); tag.ToCompacted().ShouldEqual("<div><span>something</span></div>"); }
public void render_multiple_levels_of_nesting_2() { HtmlTag tag = new HtmlTag("html").With(x => { x.Add("head", head => { head.Add("title").Text("The title"); head.Add("style").Text("the style"); }); x.Add("body/div").Text("inner text of div"); }); tag.ToCompacted().ShouldEqual( "<html><head><title>The title</title><style>the style</style></head><body><div>inner text of div</div></body></html>"); }
public void render_multiple_levels_of_nesting() { var tag = new HtmlTag("table"); tag.Add("tbody/tr/td").Text("some text"); tag.ToCompacted() .ShouldEqual("<table><tbody><tr><td>some text</td></tr></tbody></table>"); }
public void render_multiple_classes() { HtmlTag tag = new HtmlTag("div").Text("text"); tag.AddClass("a"); tag.AddClass("b"); tag.AddClass("c"); tag.ToCompacted().ShouldEqual("<div class=\"a b c\">text</div>"); }
public void render_multiple_attributes() { HtmlTag tag = new HtmlTag("table").Attr("cellPadding", "2").Attr("cellSpacing", "3"); tag.ToCompacted().ShouldEqual("<table cellPadding=\"2\" cellSpacing=\"3\"></table>"); }
public void render_multiple_classes_with_a_single_method_call() { HtmlTag tag = new HtmlTag("div").Text("text"); tag.AddClasses("a", "b", "c"); tag.ToCompacted().ShouldEqual("<div class=\"a b c\">text</div>"); }