2
using MonoDevelop.XmlEditor;
7
namespace MonoDevelop.XmlEditor.Tests.Parser
10
public class ActiveElementStartPathTestFixture
12
XmlElementPath elementPath;
13
XmlElementPath expectedElementPath;
14
string namespaceURI = "http://foo.com/foo.xsd";
17
public void PathTest1()
19
string text = "<foo xmlns='" + namespaceURI + "' ";
20
elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
22
expectedElementPath = new XmlElementPath();
23
expectedElementPath.Elements.Add(new QualifiedName("foo", namespaceURI));
24
Assert.IsTrue(elementPath.Equals(expectedElementPath),
25
"Incorrect active element path.");
29
public void PathTest2()
31
string text = "<foo xmlns='" + namespaceURI + "' ><bar ";
32
elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
34
expectedElementPath = new XmlElementPath();
35
expectedElementPath.Elements.Add(new QualifiedName("foo", namespaceURI));
36
expectedElementPath.Elements.Add(new QualifiedName("bar", namespaceURI));
37
Assert.IsTrue(expectedElementPath.Equals(elementPath),
38
"Incorrect active element path.");
42
public void PathTest3()
44
string text = "<f:foo xmlns:f='" + namespaceURI + "' ><f:bar ";
45
elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
47
expectedElementPath = new XmlElementPath();
48
expectedElementPath.Elements.Add(new QualifiedName("foo", namespaceURI, "f"));
49
expectedElementPath.Elements.Add(new QualifiedName("bar", namespaceURI, "f"));
50
Assert.IsTrue(expectedElementPath.Equals(elementPath),
51
"Incorrect active element path.");
55
public void PathTest4()
57
string text = "<x:foo xmlns:x='" + namespaceURI + "' ";
58
elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
60
expectedElementPath = new XmlElementPath();
61
expectedElementPath.Elements.Add(new QualifiedName("foo", namespaceURI, "x"));
62
Assert.IsTrue(expectedElementPath.Equals(elementPath),
63
"Incorrect active element path.");
67
public void PathTest5()
69
string text = "<foo xmlns='" + namespaceURI + "'>\r\n"+
73
elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
75
expectedElementPath = new XmlElementPath();
76
expectedElementPath.Elements.Add(new QualifiedName("foo", namespaceURI));
77
expectedElementPath.Elements.Add(new QualifiedName("y", namespaceURI));
78
Assert.IsTrue(expectedElementPath.Equals(elementPath),
79
"Incorrect active element path.");
83
public void PathTest6()
85
string text = "<bar xmlns='http://bar'>\r\n" +
86
"<foo xmlns='" + namespaceURI + "' ";
88
elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
90
expectedElementPath = new XmlElementPath();
91
expectedElementPath.Elements.Add(new QualifiedName("foo", namespaceURI));
92
Assert.IsTrue(expectedElementPath.Equals(elementPath),
93
"Incorrect active element path.");
97
/// Tests that we get no path back if we are outside the start
101
public void OutOfStartTagPathTest1()
103
string text = "<foo xmlns='" + namespaceURI + "'> ";
105
elementPath = XmlParser.GetActiveElementStartPath(text, text.Length);
106
Assert.AreEqual(0, elementPath.Elements.Count, "Should have no path.");