예제 #1
0
 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"));
 }
예제 #2
0
 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>"));
 }
예제 #3
0
 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\""));
 }
예제 #4
0
 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"));
 }
예제 #5
0
 public void When_Getting_ToString_Then_Tag_Is_Generated()
 {
     var el = new Element();
     Assert.That(el.ToString(), Text.Contains("<div />"));
 }
예제 #6
0
 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));
 }
예제 #7
0
 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>"));
 }
예제 #8
0
 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"));
     }
 }
예제 #9
0
 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>"));
 }
예제 #10
0
 public void When_SelfClosing_Then_SelfCloses()
 {
     var element = new Element();
     Assert.That(element.ToString(), Is.EqualTo("<div />"));
 }
예제 #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));
 }
예제 #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));
 }