Example #1
0
 public void CanAddAttributeWithFormat()
 {
     Element div = new Element("div");
     div.AddAttribute("id", "name_{0}", "chris");
     Assert.AreEqual("<div id=\"name_chris\"></div>", div.ToString());
     Assert.IsTrue(div.HasAttribute("id"));
 }
Example #2
0
 public void VerifyTagName()
 {
     Element para = new Element("p");
     Assert.AreEqual("p", para.TagName);
     Assert.AreEqual("<p></p>", para.ToString());
 }
Example #3
0
 public void VerifyInsertDefaultsToIndexZero()
 {
     Element select = new Element("select");
     select.Insert(new Element("option").Update("Item 1"));
     select.Insert(new Element("option").Update("Item 2"));
     Assert.AreEqual("<select><option>Item 2</option><option>Item 1</option></select>", select.ToString());
 }
Example #4
0
 public void VerifyNullElementsAreSkippedDuringInsert()
 {
     Element nullelement = null;
     Element select = new Element("select");
     select.Insert(new Element("option").Update("Item 1"), nullelement);
     Assert.AreEqual(1, select.Children.Count);
     Assert.AreEqual("<select><option>Item 1</option></select>", select.ToString());
 }
Example #5
0
 public void VerifyCanInsertByIndex()
 {
     Element select = new Element("select")
         .Append(new Element("option", "value=0").Update("Create New"))
         .Insert(0, new Element("option", "value=").Update(":: Select ::"));
     string expected = "<select><option value=\"\">:: Select ::</option><option value=\"0\">Create New</option></select>";
     Assert.AreEqual(expected, select.ToString());
     Assert.AreEqual("<option value=\"\">:: Select ::</option>", select.Children[0].ToString());
 }
Example #6
0
 public void VerifyInsert()
 {
     Element table = new Element("table");
     Element thead = new Element("thead");
     Element tr = new Element("tr");
     for (int i = 0; i < 3; i++)
     {
         tr.Insert(new Element("th").Update("Blah"));
     }
     table.Append(thead.Append(tr));
     string actual = table.ToString();
     string expected = "<table><thead><tr><th>Blah</th><th>Blah</th><th>Blah</th></tr></thead></table>";
     Assert.AreEqual(expected, actual);
 }
Example #7
0
 public void NullElementsAreNotAppendedAndDoNotThrowExceptions()
 {
     Element body = new Element("body");
     Element iamnull = null;
     Element form = new Element("form");
     body.Append(iamnull, form);
     Assert.AreEqual(1, body.Children.Count);
     Assert.AreEqual("<body><form></form></body>", body.ToString());
 }
Example #8
0
 public void NullChildElementsSkippedInCtor()
 {
     Element nullElement = null;
     Element select = new Element("select", nullElement, new Element("option").Update("chris"));
     Assert.AreEqual("<select><option>chris</option></select>", select.ToString());
 }
Example #9
0
        public void NullChildElementsAreIgnoredDuringRendering()
        {
            Element iAmNull = null;

            Element myelement = new Element("p");
            myelement.Children.Add(iAmNull);
            Assert.AreEqual("<p></p>", myelement.ToString());
        }
Example #10
0
 public void CanUpdateContentsOfElementsWithInnerHtml()
 {
     Element div = new Element("div");
     div.InnerHtml = "chris";
     Assert.AreEqual("<div>chris</div>", div.ToString());
     div.InnerHtml = "anja";
     Assert.AreEqual("<div>anja</div>", div.ToString());
 }
Example #11
0
 private void HelloWorld()
 {
     Element element = new Element("p").Update("Hello World");
     Console.WriteLine(element.ToString());
 }