2
using MonoDevelop.Ide.CodeCompletion;
3
using MonoDevelop.XmlEditor;
8
namespace MonoDevelop.XmlEditor.Tests.Schema
11
/// Tests complex content restriction elements.
14
public class RestrictionElementTestFixture : SchemaTestFixtureBase
16
ICompletionData[] childElements;
17
ICompletionData[] attributes;
18
ICompletionData[] annotationChildElements;
19
ICompletionData[] choiceChildElements;
21
public override void FixtureInit()
23
XmlElementPath path = new XmlElementPath();
24
path.Elements.Add(new QualifiedName("group", "http://www.w3.org/2001/XMLSchema"));
25
childElements = SchemaCompletionData.GetChildElementCompletionData(path);
26
attributes = SchemaCompletionData.GetAttributeCompletionData(path);
28
// Get annotation child elements.
29
path.Elements.Add(new QualifiedName("annotation", "http://www.w3.org/2001/XMLSchema"));
30
annotationChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
32
// Get choice child elements.
33
path.Elements.RemoveLast();
34
path.Elements.Add(new QualifiedName("choice", "http://www.w3.org/2001/XMLSchema"));
35
choiceChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
39
public void GroupChildElementIsAnnotation()
41
Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "annotation"),
42
"Should have a child element called annotation.");
46
public void GroupChildElementIsChoice()
48
Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "choice"),
49
"Should have a child element called choice.");
53
public void GroupChildElementIsSequence()
55
Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "sequence"),
56
"Should have a child element called sequence.");
60
public void GroupAttributeIsName()
62
Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "name"),
63
"Should have an attribute called name.");
67
public void AnnotationChildElementIsAppInfo()
69
Assert.IsTrue(SchemaTestFixtureBase.Contains(annotationChildElements, "appinfo"),
70
"Should have a child element called appinfo.");
74
public void AnnotationChildElementIsDocumentation()
76
Assert.IsTrue(SchemaTestFixtureBase.Contains(annotationChildElements, "documentation"),
77
"Should have a child element called appinfo.");
81
public void ChoiceChildElementIsSequence()
83
Assert.IsTrue(SchemaTestFixtureBase.Contains(choiceChildElements, "element"),
84
"Should have a child element called element.");
87
protected override string GetSchema()
89
return "<xs:schema targetNamespace=\"http://www.w3.org/2001/XMLSchema\" blockDefault=\"#all\" elementFormDefault=\"qualified\" version=\"1.0\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xml:lang=\"EN\" xmlns:hfp=\"http://www.w3.org/2001/XMLSchema-hasFacetAndProperty\">\r\n" +
91
" <xs:element name=\"group\" type=\"xs:namedGroup\" id=\"group\">\r\n" +
92
" </xs:element>\r\n" +
94
" <xs:element name=\"annotation\" id=\"annotation\">\r\n" +
95
" <xs:complexType>\r\n" +
96
" <xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
97
" <xs:element name=\"appinfo\"/>\r\n" +
98
" <xs:element name=\"documentation\"/>\r\n" +
100
" <xs:attribute name=\"id\" type=\"xs:ID\"/>\r\n" +
101
" </xs:complexType>\r\n" +
102
" </xs:element>\r\n" +
105
" <xs:complexType name=\"namedGroup\">\r\n" +
106
" <xs:complexContent>\r\n" +
107
" <xs:restriction base=\"xs:realGroup\">\r\n" +
108
" <xs:sequence>\r\n" +
109
" <xs:element ref=\"xs:annotation\" minOccurs=\"0\"/>\r\n" +
110
" <xs:choice minOccurs=\"1\" maxOccurs=\"1\">\r\n" +
111
" <xs:element ref=\"xs:choice\"/>\r\n" +
112
" <xs:element name=\"sequence\"/>\r\n" +
113
" </xs:choice>\r\n" +
114
" </xs:sequence>\r\n" +
115
" <xs:attribute name=\"name\" use=\"required\" type=\"xs:NCName\"/>\r\n" +
116
" <xs:attribute name=\"ref\" use=\"prohibited\"/>\r\n" +
117
" <xs:attribute name=\"minOccurs\" use=\"prohibited\"/>\r\n" +
118
" <xs:attribute name=\"maxOccurs\" use=\"prohibited\"/>\r\n" +
119
" <xs:anyAttribute namespace=\"##other\" processContents=\"lax\"/>\r\n" +
120
" </xs:restriction>\r\n" +
121
" </xs:complexContent>\r\n" +
122
" </xs:complexType>\r\n" +
124
" <xs:complexType name=\"realGroup\">\r\n" +
125
" <xs:sequence>\r\n" +
126
" <xs:element ref=\"xs:annotation\" minOccurs=\"0\"/>\r\n" +
127
" <xs:choice minOccurs=\"0\" maxOccurs=\"1\">\r\n" +
128
" <xs:element name=\"all\"/>\r\n" +
129
" <xs:element ref=\"xs:choice\"/>\r\n" +
130
" <xs:element name=\"sequence\"/>\r\n" +
131
" </xs:choice>\r\n" +
132
" </xs:sequence>\r\n" +
133
" <xs:anyAttribute namespace=\"##other\" processContents=\"lax\"/>\r\n" +
134
" </xs:complexType>\r\n" +
136
" <xs:element name=\"choice\" id=\"choice\">\r\n" +
137
" <xs:complexType>\r\n" +
138
" <xs:choice minOccurs=\"0\" maxOccurs=\"1\">\r\n" +
139
" <xs:element name=\"element\"/>\r\n" +
140
" <xs:element name=\"sequence\"/>\r\n" +
141
" </xs:choice>\r\n" +
142
" </xs:complexType>\r\n" +
143
" </xs:element>\r\n" +