public void WithLocalName_should_change_nominal() { DomName n = DomName.Create(DomNamespace.Default, "default"); n = n.WithLocalName("name"); Assert.Same("name", n.LocalName); }
public void Equals_qualified_names_equals_equatable() { DomName n = DomName.Create(DomNamespace.Default, "default"); Assert.False(n.Equals(null)); Assert.True(n.Equals(n)); }
public void WithNamespace_should_change_nominal() { DomName n = DomName.Create(DomNamespace.Default, "default"); DomNamespace nu = DomNamespace.Create("https://example.com"); n = n.WithNamespace(nu); Assert.Same(nu, n.Namespace); }
public void Create_should_generate_xml_semantics() { var dom = DomName.Create("xmlns:a"); Assert.Equal("xmlns:a", dom.LocalName); Assert.Null(dom.Prefix); Assert.Empty(dom.NamespaceUri); Assert.Equal("xmlns", dom.TryXmlSemantics().Value.Prefix); Assert.Equal("a", dom.TryXmlSemantics().Value.LocalName); }
public void Document_OuterXml_should_treat_prefixed_name_as_is() { var doc = new DomDocument(); doc.AppendElement(DomName.Create("prefix:name")); // In the default DomNameContext, the prefix is treated as part of the // local name, and thus prints out as-is Assert.Equal("<prefix:name/>", doc.OuterXml); }
public void Action_will_not_throw_on_context_that_allows_it(Action <DomName> action) { action = RebindDelegate(action); // This name is invalid in XML but valid in HTML var invalidXmlName = DomName.Create(DomNamespace.Default, "t=s"); Document.NameContext = DomNameContext.Html; Given(invalidXmlName).Expect(action).Not.ToThrow.Exception(); }
public void Add_will_detect_duplicates_on_map_key_equality() { var list = new List <DomAttribute>(); var subject = new DomAttributeCollectionImpl(list, DomNameComparer.IgnoreCase); subject.Add(new DomAttribute(DomName.Create("a"))); var ex = Record.Exception(() => subject.Add(new DomAttribute(DomName.Create("A")))); Assert.Contains("already exists", ex.Message); }
public void Action_will_throw_on_invalid_name(Action <DomName> action) { action = RebindDelegate(action); // This name is invalid in XML but valid in HTML var invalidXmlName = DomName.Create(DomNamespace.Default, "t=s"); Given(invalidXmlName).Expect(action).ToThrow.Exception <ArgumentException>(); Given(invalidXmlName).Expect(action).ToThrow.Message.StartsWith( "Name `t=s' cannot be used in this context" ); }
public void Equals_operator_should_apply() { DomName n = DomName.Create(DomNamespace.Default, "default"); DomName m = n; Assert.False(n == null); Assert.True(n != null); Assert.False(null == n); Assert.True(null != n); Assert.True(m == n); Assert.False(m != n); }
public void NodeFactory_for_default_document_creates_HTML_elements() { var nodeFactory = HtmlProviderFactory.Instance.CreateDocument().NodeFactory; Assert.Equal( typeof(HtmlElement), nodeFactory.GetElementNodeType(DomName.Create("x")) ); Assert.IsInstanceOf <HtmlElement>( nodeFactory.CreateElement(DomName.Create("x")) ); }
public void Document_OuterXml_should_not_print_prefixed_name_prefix_in_XML_name_context() { var doc = new DomDocument { NameContext = DomNameContext.Xml, }; doc.AppendElement(DomName.Create("prefix:name")); // The prefix was used but not bound to a namespace, hence it // is not printed out in XML, and there are no XMLNS attributes. // TODO It is possible that XMLNS might not even get added until _at least_ one // binding is present Assert.Equal("<name xmlns=\"http://www.w3.org/2000/xmlns/\"/>", doc.OuterXml); }
private void ByTag() { string tagName = tq.ConsumeElementSelector(); if (tagName.Length == 0) { throw Failure.EmptyString("tagName"); } // namespaces: if element name is "abc:def", selector must be "abc|def", so flip: if (tagName.Contains("|")) { tagName = tagName.Replace("|", ":"); } evals.Add(new Evaluator.Tag(DomName.Create(tagName.Trim().ToLower()))); }
public void Create_local_name_is_required() { Assert.Throws <ArgumentException>(() => { DomName.Create(DomNamespace.Default, ""); }); Assert.Throws <ArgumentNullException>(() => { DomName.Create(DomNamespace.Default, null); }); }
public void NodeFactory_creates_HTML_elements() { Assert.IsInstanceOf <HtmlElement>( new HtmlDocument().NodeFactory.CreateElement(DomName.Create("any")) ); }
protected DomContainerDefinition(string name) : this(DomName.Create(name)) { }
protected internal DomProcessingInstructionDefinition(string name) : base(DomName.Create(name)) { }
public HtmlAttributeDefinition(string name) : base(DomName.Create(name)) { }
public override DomName GetAttributeName(Type attributeType) { return(DomName.Create("hey:" + attributeType.Name)); }
internal HtmlElementDefinition(string tagName) : base(DomName.Create(tagName)) { ElementNodeType = typeof(HtmlElement); }
public override DomName GetElementName(Type elementType) { return(DomName.Create("hey:" + elementType.Name)); }
public new HtmlAttributeDefinition GetAttributeDefinition(string name) { return((HtmlAttributeDefinition)base.GetDomAttributeDefinition(DomName.Create(name))); }
public new HtmlElementDefinition GetElementDefinition(string name) { return((HtmlElementDefinition)base.GetDomElementDefinition(DomName.Create(name))); }