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());
        }
Example #2
0
        public void SingleElementWithNamespacePrefixFoundByXPath()
        {
            string xml =
                "<f:root xmlns:f='http://foo.com'>\r\n" +
                "\t<f:foo></f:foo>\r\n" +
                "</f:root>";
            XmlNamespaceCollection namespaces = new XmlNamespaceCollection();

            namespaces.Add(new XmlNamespace("fo", "http://foo.com"));
            XPathQuery query = new XPathQuery(xml, namespaces);

            XPathNodeMatch[] nodes = query.FindNodes("//fo:foo");
            XPathNodeMatch   node  = nodes[0];

            string                   nodeValue    = "f:foo";
            string                   displayValue = "<f:foo>";
            int                      lineNumber   = 1;
            int                      linePosition = 2;
            XPathNodeType            nodeType     = XPathNodeType.Element;
            XPathNodeMatch           expectedNode = new XPathNodeMatch(nodeValue, displayValue, lineNumber, linePosition, nodeType);
            XPathNodeMatchComparison comparison   = new XPathNodeMatchComparison();

            Assert.IsTrue(comparison.AreEqual(expectedNode, node), comparison.GetReasonForNotMatching());
            Assert.AreEqual(1, nodes.Length);
        }
Example #3
0
		/// <summary>
		/// Gets the list of namespaces in the namespace list.
		/// </summary>
		public XmlNamespaceCollection GetNamespaces()
		{
			XmlNamespaceCollection namespaces = new XmlNamespaceCollection();
			for (int i = 0; i < namespacesDataGridView.Rows.Count - 1; ++i) {
				DataGridViewRow row = namespacesDataGridView.Rows[i];
				string prefix = GetPrefix(row);
				string uri = GetNamespace(row);
				if (prefix.Length == 0 && uri.Length == 0) {
					// Ignore.
				} else {
					namespaces.Add(new XmlNamespace(prefix, uri));
				}
			}
			return namespaces;
		}
Example #4
0
        public void GetRootElementCompletionReturnsRootElementsFromBothFooSchemas()
        {
            XmlNamespaceCollection namespaces = new XmlNamespaceCollection();

            namespaces.Add(new XmlNamespace(String.Empty, "foo"));
            XmlCompletionItemCollection items = schemas.GetRootElementCompletion(namespaces);

            items.Sort();

            List <XmlCompletionItem> expectedItems = new List <XmlCompletionItem>();

            expectedItems.Add(new XmlCompletionItem("duplicate-foo-note", XmlCompletionItemType.XmlElement));
            expectedItems.Add(new XmlCompletionItem("foo-note", XmlCompletionItemType.XmlElement));

            Assert.AreEqual(expectedItems.ToArray(), items.ToArray());
        }
		public void SingleElementWithNamespacePrefixFoundByXPath()
		{
			string xml = 
				"<f:root xmlns:f='http://foo.com'>\r\n" +
				"\t<f:foo></f:foo>\r\n" +
				"</f:root>";
			XmlNamespaceCollection namespaces = new XmlNamespaceCollection();
			namespaces.Add(new XmlNamespace("fo", "http://foo.com"));
			XPathQuery query = new XPathQuery(xml, namespaces);
			XPathNodeMatch[] nodes = query.FindNodes("//fo:foo");
			XPathNodeMatch node = nodes[0];
			
			string nodeValue = "f:foo";
			string displayValue = "<f:foo>";
			int lineNumber = 1;
			int linePosition = 2;
			XPathNodeType nodeType = XPathNodeType.Element;
			XPathNodeMatch expectedNode = new XPathNodeMatch(nodeValue, displayValue, lineNumber, linePosition, nodeType);
			XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
			Assert.IsTrue(comparison.AreEqual(expectedNode, node), comparison.GetReasonForNotMatching());
			Assert.AreEqual(1, nodes.Length);
		}
Example #6
0
 /// <summary>
 /// Adds project hosting xml namespaces before serialization.
 /// </summary>
 public override void Close()
 {
     base.Close();
     XmlNamespaceCollection.Add("issues", "http://schemas.google.com/projecthosting/issues/2009");
 }
        public void GetRootElementCompletionReturnsRootElementsFromBothFooSchemas()
        {
            XmlNamespaceCollection namespaces = new XmlNamespaceCollection();
            namespaces.Add(new XmlNamespace(String.Empty, "foo"));
            XmlCompletionItemCollection items = schemas.GetRootElementCompletion(namespaces);
            items.Sort();

            List<XmlCompletionItem> expectedItems = new List<XmlCompletionItem>();
            expectedItems.Add(new XmlCompletionItem("duplicate-foo-note", XmlCompletionItemType.XmlElement));
            expectedItems.Add(new XmlCompletionItem("foo-note", XmlCompletionItemType.XmlElement));

            Assert.AreEqual(expectedItems.ToArray(), items.ToArray());
        }