public void HasAttribute_should_be_false() { DomContainer doc = new DomDocument().AppendElement("s"); var text = doc.AppendText(" "); Assert.False(text.HasAttribute("anything")); }
public void RemoveAttribute_should_be_nop() { DomContainer doc = new DomDocument().AppendElement("s"); var text = doc.AppendText(" "); Assert.Same(text, text.RemoveAttribute("anything")); }
public void Append_should_disallow_text_in_document() { DomDocument doc = new DomDocument(); Assert.Throws <InvalidOperationException>( () => doc.AppendText("text")); }
public void SetValue_is_equivalent_to_Data_property() { DomContainer doc = new DomDocument().AppendElement("s"); var html = doc.AppendText(" ").SetData("nyc"); Assert.IsInstanceOf <DomText>(html); Assert.Equal("nyc", html.Data); }
public void test_add_child_document_element_implies_parent_and_owner() { DomDocument doc = new DomDocument(); var html = doc.AppendText("leading ws"); Assert.That(html.ChildNodes.Count, Is.EqualTo(0)); Assert.That(html.OwnerDocument, Is.SameAs(doc)); Assert.That(html.ParentNode, Is.SameAs(doc)); Assert.That(html.ParentElement, Is.Null); }
public void Doctype_should_get_the_document_type() { var doc = new DomDocument(); var dt = doc.CreateDocumentType("html"); dt.AppendTo(doc); doc.AppendText(" "); Assert.Same(dt, doc.Doctype); }
public void test_basic_property_access() { DomDocument doc = new DomDocument(); string ws = "leading ws"; var html = doc.AppendText(ws); Assert.That(html.ToString(), Is.EqualTo(ws)); Assert.That(html.TextContent, Is.EqualTo(ws)); Assert.That(html.Data, Is.EqualTo(ws)); Assert.That(html.NodeValue, Is.EqualTo(ws)); }
public void test_outer_text_domelement() { DomDocument doc = new DomDocument(); var html = doc.AppendText("leading ws"); string htmlText = "leading ws"; Assert.That(html.OuterText, Is.EqualTo(htmlText)); Assert.That(html.ToString(), Is.EqualTo(htmlText)); Assert.That(doc.OuterText, Is.EqualTo(htmlText)); Assert.That(doc.ToString(), Is.EqualTo(htmlText)); }
public void test_replace_with_document_element() { DomDocument doc = new DomDocument(); var html = doc.AppendText("leading ws"); var head = doc.CreateElement("head"); var result = html.ReplaceWith(head); Assert.That(doc.ToXml(), Is.EqualTo("<head />")); Assert.That(result, Is.SameAs(head)); }