public void ContainsReturnsTrueForKnownNamespaceWhenPrefixIsEmptyString()
        {
            XmlNamespace ns = new XmlNamespace(String.Empty, "namespace");
            namespaceCollection.Add(ns);

            Assert.IsTrue(namespaceCollection.Contains(ns));
        }
        public void GetNamespaceForPrefixReturnsPrefixForKnownNamespaceInCollection()
        {
            XmlNamespace ns = new XmlNamespace("prefix", "namespace");
            namespaceCollection.Add(ns);

            Assert.AreEqual("namespace", namespaceCollection.GetNamespaceForPrefix("prefix"));
        }
        public void GetNamespaceForPrefixReturnsEmptyStringForUnknownNamespaceInCollection()
        {
            XmlNamespace ns = new XmlNamespace("prefix", "namespace");
            namespaceCollection.Add(ns);

            Assert.AreEqual(String.Empty, namespaceCollection.GetNamespaceForPrefix("unknown-prefix"));
        }
        public void ContainsReturnsFalseForKnownNamespaceWhenPrefixDoesNotMatch()
        {
            XmlNamespace ns = new XmlNamespace("prefix", "namespace");
            namespaceCollection.Add(ns);
            XmlNamespace namespaceWithDifferentPrefix = new XmlNamespace(String.Empty, "namespace");

            Assert.IsFalse(namespaceCollection.Contains(namespaceWithDifferentPrefix));
        }
		public void XmlNamespaceInScopeForRootElementWithNoNamespace()
		{
			string xml = "<root ";
			XmlElementPath path = XmlParser.GetActiveElementStartPath(xml, xml.Length);
			
			XmlNamespace[] expectedNamespaces = new XmlNamespace[] {xmlNamespace};
			
			Assert.AreEqual(expectedNamespaces, path.NamespacesInScope.ToArray());
		}
        public void ContainsReturnsFalseForUnknownNamespace()
        {
            XmlNamespace ns = new XmlNamespace("prefix", "namespace");
            namespaceCollection.Add(ns);

            XmlNamespace unknownNamespace = new XmlNamespace("prefix", "unknown-namespace");

            Assert.IsFalse(namespaceCollection.Contains(unknownNamespace));
        }
		public void TwoNamespacesInScopeForRootElement()
		{
			string xml = "<root xmlns='test' ";
			XmlElementPath path = XmlParser.GetActiveElementStartPath(xml, xml.Length);
			
			XmlNamespace testNamespace = new XmlNamespace(String.Empty, "test");
			XmlNamespace[] expectedNamespaces = new XmlNamespace[] {xmlNamespace, testNamespace};
			
			Assert.AreEqual(expectedNamespaces, path.NamespacesInScope.ToArray());
		}
		public void TwoNamespacesInScopeAndOneNamespaceUsedInPathNamespacesWithoutPathsReturnsUnusedNamespace()
		{
			path.AddElement(new QualifiedName("foo-root", "http://foo"));
			path.NamespacesInScope.Add(fooNamespace);
			path.NamespacesInScope.Add(barNamespace);
			
			XmlElementPathsByNamespace pathsByNamespaces = new XmlElementPathsByNamespace(path);
			
			XmlNamespace[] expectedNamespaces = new XmlNamespace[] {barNamespace};
			Assert.AreEqual(expectedNamespaces, pathsByNamespaces.NamespacesWithoutPaths.ToArray());
		}
		public void ToArrayReturnsXmlNamespaceItemsInCollection()
		{
			XmlNamespace a = new XmlNamespace("a", "a-ns");
			XmlNamespace b = new XmlNamespace("b", "b-ns");
			
			namespaceCollection.Add(a);
			namespaceCollection.Add(b);
			
			XmlNamespace[] expectedArray = new XmlNamespace[] { a, b };
			
			Assert.AreEqual(expectedArray, namespaceCollection.ToArray());
		}
Пример #10
0
 public void SettingPrefixPropertyUpdatesPrefix()
 {
     XmlNamespace ns = new XmlNamespace("s", "http://sharpdevelop.com");
     ns.Prefix = "a";
     Assert.AreEqual("a", ns.Prefix);
 }
 public void PrefixAndNamespaceToString()
 {
     XmlNamespace ns = new XmlNamespace("f", "http://foo.com");
     Assert.AreEqual("Prefix [f] Uri [http://foo.com]", ns.ToString());
 }
 public void Init()
 {
     lhs = new XmlNamespace();
     rhs = new XmlNamespace();
 }
 bool HavePathForNamespace(XmlNamespace ns)
 {
     return(pathsByNamespace.ContainsKey(ns.Name));
 }
Пример #14
0
 public void HasNamePropertyReturnsFalseWhenNamespaceIsEmptyString()
 {
     XmlNamespace ns = new XmlNamespace("s", String.Empty);
     Assert.IsFalse(ns.HasName);
 }
		public void Init()
		{
			path = new XmlElementPath();
			fooNamespace = new XmlNamespace("foo", "http://foo");
			barNamespace = new XmlNamespace("bar", "http://bar");
		}
Пример #16
0
 public void HasNamePropertyReturnsTrueWhenNamespaceIsNotEmptyString()
 {
     XmlNamespace ns = new XmlNamespace("s", "ns");
     Assert.IsTrue(ns.HasName);
 }
		public void CreateQualifiedNameWithXmlNamespaceObject()
		{
			XmlNamespace ns = new XmlNamespace("prefix", "namespace");
			QualifiedName name = new QualifiedName("elementName", ns);
			Assert.AreEqual("prefix:elementName [namespace]", name.ToString());
		}
Пример #18
0
 public QualifiedName(string name, XmlNamespace ns)
     : this(name, ns.Name, ns.Prefix)
 {
 }
Пример #19
0
 public void NullNamespaceAndPrefixReplacedByEmptyStringsWhenCreatingXmlNamespaceInstance()
 {
     XmlNamespace ns = new XmlNamespace(null, null);
     Assert.AreEqual(String.Empty, ns.Name);
     Assert.AreEqual(String.Empty, ns.Prefix);
 }
Пример #20
0
 public void SettingNamePropertyUpdatesNamespace()
 {
     XmlNamespace ns = new XmlNamespace("s", "http://sharpdevelop.com");
     ns.Name = "new-ns";
     Assert.AreEqual("new-ns", ns.Name);
 }
Пример #21
0
 public void SettingPrefixPropertyToNullUpdatesPrefixToEmptyString()
 {
     XmlNamespace ns = new XmlNamespace("s", "http://sharpdevelop.com");
     ns.Prefix = null;
     Assert.AreEqual(String.Empty, ns.Prefix);
 }
Пример #22
0
 public void SimpleNamespace()
 {
     XmlNamespace ns = new XmlNamespace("s", "http://sharpdevelop.com");
     Assert.AreEqual("s", ns.Prefix);
     Assert.AreEqual("http://sharpdevelop.com", ns.Uri);
 }
		public void Init()
		{
			 xmlNamespace = new XmlNamespace("xml", "http://www.w3.org/XML/1998/namespace");
		}