~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/DisplayBindings/XmlEditor/Test/XPath/NamespaceXPathQueryTestFixture.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.Collections.Generic;
 
6
using System.Collections.ObjectModel;
 
7
using System.Xml;
 
8
using System.Xml.XPath;
 
9
 
 
10
using ICSharpCode.XmlEditor;
 
11
using NUnit.Framework;
 
12
using XmlEditor.Tests.Utils;
 
13
 
 
14
namespace XmlEditor.Tests.XPath
 
15
{
 
16
        [TestFixture]
 
17
        public class NamespaceXPathQueryTestFixture
 
18
        {
 
19
                XPathNodeMatch node;
 
20
                XPathNodeMatch xmlNamespaceNode;
 
21
                XPathNodeMatch[] nodes;
 
22
                
 
23
                [SetUp]
 
24
                public void Init()
 
25
                {
 
26
                        string xml = "<root xmlns='http://foo.com'/>";
 
27
                        XPathQuery query = new XPathQuery(xml);
 
28
                        nodes = query.FindNodes("//namespace::*");
 
29
                        node = nodes[0];
 
30
                        xmlNamespaceNode = nodes[1];
 
31
                }
 
32
                
 
33
                [Test]
 
34
                public void TwoNamespaceNodesFoundByXPath()
 
35
                {
 
36
                        Assert.AreEqual(2, nodes.Length);
 
37
                }
 
38
                
 
39
                [Test]
 
40
                public void FooNamespaceNodeFoundByXPath()
 
41
                {
 
42
                        string nodeValue = "xmlns=\"http://foo.com\"";
 
43
                        string displayValue = "xmlns=\"http://foo.com\"";
 
44
                        int lineNumber = 0;
 
45
                        int linePosition = 6;
 
46
                        XPathNodeType nodeType = XPathNodeType.Namespace;
 
47
                        XPathNodeMatch expectedMatch = new XPathNodeMatch(nodeValue, displayValue, lineNumber, linePosition, nodeType);
 
48
                        XPathNodeMatchComparison comparison = new XPathNodeMatchComparison();
 
49
                        Assert.IsTrue(comparison.AreEqual(expectedMatch, node), comparison.GetReasonForNotMatching());
 
50
                }
 
51
                
 
52
                [Test]
 
53
                public void XmlNamespaceNodeFoundByXPathHasNoLineInfo()
 
54
                {
 
55
                        Assert.IsFalse(xmlNamespaceNode.HasLineInfo());
 
56
                }
 
57
                
 
58
                [Test]
 
59
                public void XmlNamespaceNodeFoundByXPathHasW3OrgSchemaNamespace()
 
60
                {
 
61
                        Assert.AreEqual("xmlns:xml=\"http://www.w3.org/XML/1998/namespace\"", xmlNamespaceNode.Value);
 
62
                }
 
63
        }
 
64
}