public void GetNamespace_should_obtain_namespace_from_prefix_nominal() { var doc = new DomDocument(); doc.AppendElement("root").Attribute("xmlns:a", "https://example.com/a"); IDomNamePrefixResolver subject = new DomElementPrefixResolver(doc.DocumentElement); Assert.Equal("https://example.com/a", subject.GetNamespace("a", DomScope.TargetAndAncestors)); }
public void RegisterPrefix_should_assign_prefixes_to_attributes() { var doc = new DomDocument(); doc.AppendElement("root"); IDomNamePrefixResolver subject = new DomElementPrefixResolver(doc.DocumentElement); subject.RegisterPrefix(DomNamespace.Create("https://example.com/a"), "a"); Assert.Equal("https://example.com/a", doc.DocumentElement.Attribute("xmlns:a")); }
public void GetPrefixes_should_obtain_prefixes_from_namespace() { var doc = new DomDocument(); doc.AppendElement("root").Attribute("xmlns:a", "https://example.com/a") .Attribute("xmlns:also", "https://example.com/a"); IDomNamePrefixResolver subject = new DomElementPrefixResolver(doc.DocumentElement); Assert.Equal(new [] { "a", "also" }, subject.GetPrefixes(DomNamespace.Create("https://example.com/a"), DomScope.Target)); }