public void Can_Add_Objects_As_Attribs_And_Values_And_Will_use_ToString()
 {
     var attribs = new HtmlAttributes();
     var element = new Element();
     attribs.Add(element, 96);
     Assert.That(attribs[element.ToString()], Is.EqualTo("96"));
 }
 public void Tag_With_Four_Or_More_Attributes_Renders_Correctly()
 {
     var element = new Element {InnerText = "This is Text", Id = "MyID", Class = "MyClass"};
     element["Style"] = "MyStyle";
     element["onclick"] = "MyOnClick";
     element["Gizmodo"] = "A cool Website";
     Assert.That(element.ToString(), Is.EqualTo("<div id=\"MyID\" class=\"MyClass\" Style=\"MyStyle\" onclick=\"MyOnClick\" Gizmodo=\"A cool Website\">This is Text</div>"));
 }
 public void When_Getting_ToString_With_Id_Then_Id_Attribute_Is_Generated()
 {
     var el = new Element {Id = "goose"};
     Assert.That(el.ToString(), Text.Contains("id=\"goose\""));
 }
 public void When_Getting_ToString_With_A_Empty_Attribute_Then_It_Is_Not_Generated()
 {
     var el = new Element {Id = "goose"};
     el["checked"] = null;
     Assert.That(el.ToString(), Text.DoesNotContain("checked"));
 }
 public void When_Getting_ToString_Then_Tag_Is_Generated()
 {
     var el = new Element();
     Assert.That(el.ToString(), Text.Contains("<div />"));
 }
 public void When_value_is_empty_string_should_still_be_rendered()
 {
     var element = new Element("input", new Hash(value => ""));
     string actual = element.ToString();
     string expected = "<input value=\"\"/>";
     Assert.That(actual, Is.EqualTo(expected));
 }
 public void Tag_With_Escaped_Flag_Has_Escaped_Content_When_Rendered()
 {
     var element = new Element {InnerText = "This is Text", EscapeInnerText = true};
     Assert.That(element.ToString(), Is.EqualTo("<div >/*<![CDATA[*/\r\nThis is Text\r\n//]]></div>"));
 }
 public void When_Tag_Has_No_Value_Exception_Is_Thrown()
 {
     var element = new Element {Tag = ""};
     try
     {
         string val = element.ToString();
     }
     catch (System.Exception e)
     {
         Assert.That(e.Message, Is.EqualTo("tag must contain a value"));
     }
 }
 public void Tag_Will_Close_With_Full_Tag_If_There_Is_InnerText()
 {
     var element = new Element {InnerText = "This is Text"};
     Assert.That(element.ToString(), Is.EqualTo("<div >This is Text</div>"));
 }
Exemple #10
0
 public void When_SelfClosing_Then_SelfCloses()
 {
     var element = new Element();
     Assert.That(element.ToString(), Is.EqualTo("<div />"));
 }
Exemple #11
0
 public void When_label_element_then_for_attribute_should_have_periods_replaced_with_hyphens()
 {
     var element = new Element("label");
     element["for"] = "foo.bar";
     element.InnerText = "Test";
     string actual = element.ToString();
     string expected = "<label for=\"foo-bar\">Test</label>";
     Assert.That(actual, Is.EqualTo(expected));
 }
Exemple #12
0
 public void When_id_has_period_should_be_replaced_with_hyphen()
 {
     var element = new Element {Id = "foo.bar"};
     string actual = element.ToString();
     string expected = "<div id=\"foo-bar\"/>";
     Assert.That(actual, Is.EqualTo(expected));
 }