2
using MonoDevelop.Ide.CodeCompletion;
3
using MonoDevelop.XmlEditor;
8
namespace MonoDevelop.XmlEditor.Tests.Schema
11
/// Tests that nested schema choice elements are handled.
12
/// This happens in the NAnt schema 0.85.
15
public class NestedChoiceTestFixture : SchemaTestFixtureBase
17
ICompletionData[] noteChildElements;
18
ICompletionData[] titleChildElements;
20
public override void FixtureInit()
22
// Get note child elements.
23
XmlElementPath path = new XmlElementPath();
24
path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
26
noteChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
28
// Get title child elements.
29
path.Elements.Add(new QualifiedName("title", "http://www.w3schools.com"));
30
titleChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
34
public void TitleHasTwoChildElements()
36
Assert.AreEqual(2, titleChildElements.Length,
37
"Should be 2 child elements.");
41
public void TextHasNoChildElements()
43
XmlElementPath path = new XmlElementPath();
44
path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
45
path.Elements.Add(new QualifiedName("text", "http://www.w3schools.com"));
46
Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length,
47
"Should be no child elements.");
51
public void NoteHasTwoChildElements()
53
Assert.AreEqual(2, noteChildElements.Length,
54
"Should be two child elements.");
58
public void NoteChildElementIsText()
60
Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "text"),
61
"Should have a child element called text.");
65
public void NoteChildElementIsTitle()
67
Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "title"),
68
"Should have a child element called title.");
71
protected override string GetSchema()
73
return "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\" elementFormDefault=\"qualified\">\r\n" +
74
"\t<xs:element name=\"note\">\r\n" +
75
"\t\t<xs:complexType> \r\n" +
76
"\t\t\t<xs:choice>\r\n" +
77
"\t\t\t\t<xs:element ref=\"title\"/>\r\n" +
78
"\t\t\t\t<xs:element name=\"text\" type=\"xs:string\"/>\r\n" +
79
"\t\t\t</xs:choice>\r\n" +
80
"\t\t</xs:complexType>\r\n" +
81
"\t</xs:element>\r\n" +
82
"\t<xs:element name=\"title\">\r\n" +
83
"\t\t<xs:complexType> \r\n" +
84
"\t\t\t<xs:choice>\r\n" +
85
"\t\t\t\t<xs:element name=\"foo\" type=\"xs:string\"/>\r\n" +
86
"\t\t\t\t<xs:element name=\"bar\" type=\"xs:string\"/>\r\n" +
87
"\t\t\t</xs:choice>\r\n" +
88
"\t\t</xs:complexType>\r\n" +
89
"\t</xs:element>\r\n" +