public void Attributes_null_and_no_values() { DomDocument doc = new DomDocument(); Assert.Null(doc.Attributes); Assert.Same(doc, doc.Attribute("s", "s")); Assert.Null(doc.Attribute("s")); }
public void GetName_is_case_insensitive_by_Default_accessing_attributes() { var ele = new DomDocument().CreateElement("s"); Assert.True(ele.NameContext.Comparer.Equals("a", "A")); var attr = ele.Attribute("a", "b"); Assert.Equal("b", ele.Attribute("A")); Assert.Same(ele.Attributes[0], ele.Attributes["A"]); }
public void GetName_is_case_sensitive_in_xml() { var ele = new DomDocument { NameContext = DomNameContext.Xml }.AppendElement("s"); ele.Attribute("a", "b"); Assert.False(ele.NameContext.Comparer.Equals("a", "A")); Assert.Equal(DomNameComparer.Ordinal, ele.Attributes._Comparer); Assert.Null(ele.Attribute("A"), "should be null because of case-sensitivity"); }
public void test_attributes_null_and_no_values() { DomDocument doc = new DomDocument(); Assert.That(doc.Attributes, Is.Null); // TODO Review this behavior: should it be an error? Assert.That(doc.Attribute("s", "s"), Is.Null); }
public void NameContext_should_inherit_from_element() { var html = new DomDocument().AppendElement("html"); html.NameContext = DomNameContext.Html; html.Attribute("s", "t"); var attr = html.Attributes[0]; Assert.Equal(DomNameContext.Html, attr.NameContext); }
public void BaseUri_should_inherit() { var html = new DomDocument().AppendElement("html"); var example = new Uri("https://example.com"); html.BaseUri = example; html.Attribute("hello", "world"); var attr = html.Attributes[0]; Assert.Equal(example, attr.BaseUri); }
public void GetName_will_notify_mutation_events_when_name_content_changes() { var ele = new DomDocument().CreateElement("s"); ele.NameContext = DomNameContext.Xml; ele.Attribute("a", "a").Attribute("A", "A") .Attribute("b", "b").Attribute("B", "B") .Attribute("c", "c").Attribute("C", "C"); var evts = new TestActionDispatcher <DomAttributeEvent>(_ => {}); var observer = ele.OwnerDocument.ObserveAttributes(ele, evts.Invoke); ele.NameContext = DomNameContext.Html; // Should have generated several events indicating that attributes were Assert.Equal(3, evts.CallCount); Assert.Equal("A", evts.ArgsForCall(0).LocalName); Assert.Equal("B", evts.ArgsForCall(1).LocalName); Assert.Equal("C", evts.ArgsForCall(2).LocalName); }