2
using MonoDevelop.XmlEditor;
3
using MonoDevelop.Ide.CodeCompletion;
8
namespace MonoDevelop.XmlEditor.Tests.Schema
11
/// Tests elements that are abstract and require substitution groups.
14
public class AbstractElementTestFixture : SchemaTestFixtureBase
16
ICompletionData[] itemsElementChildren;
17
ICompletionData[] fileElementAttributes;
18
ICompletionData[] fileElementChildren;
20
public override void FixtureInit()
22
XmlElementPath path = new XmlElementPath();
24
path.Elements.Add(new QualifiedName("project", "http://foo"));
25
path.Elements.Add(new QualifiedName("items", "http://foo"));
27
itemsElementChildren = SchemaCompletionData.GetChildElementCompletionData(path);
29
path.Elements.Add(new QualifiedName("file", "http://foo"));
31
fileElementAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
32
fileElementChildren = SchemaCompletionData.GetChildElementCompletionData(path);
36
public void ItemsElementHasTwoChildElements()
38
Assert.AreEqual(2, itemsElementChildren.Length,
39
"Should be 2 child elements.");
43
public void ReferenceElementIsChildOfItemsElement()
45
Assert.IsTrue(SchemaTestFixtureBase.Contains(itemsElementChildren, "reference"));
49
public void FileElementIsChildOfItemsElement()
51
Assert.IsTrue(SchemaTestFixtureBase.Contains(itemsElementChildren, "file"));
55
public void FileElementHasAttributeNamedType()
57
Assert.IsTrue(SchemaTestFixtureBase.Contains(fileElementAttributes, "type"));
61
public void FileElementHasTwoChildElements()
63
Assert.AreEqual(2, fileElementChildren.Length, "Should be 2 child elements.");
66
protected override string GetSchema()
68
return "<xs:schema targetNamespace=\"http://foo\" xmlns:foo=\"http://foo\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\">\r\n" +
69
" <xs:element name=\"project\">\r\n" +
70
" <xs:complexType>\r\n" +
71
" <xs:sequence>\r\n" +
72
" <xs:group ref=\"foo:projectItems\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\r\n" +
73
" </xs:sequence>\r\n" +
74
" </xs:complexType>\r\n" +
75
" </xs:element>\r\n" +
77
" <xs:group name=\"projectItems\">\r\n" +
79
" <xs:element name=\"items\" type=\"foo:itemGroupType\"/>\r\n" +
80
" <xs:element name=\"message\" type=\"xs:string\"/>\r\n" +
84
" <xs:complexType name=\"itemGroupType\">\r\n" +
85
" <xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
86
" <xs:element ref=\"foo:item\"/>\r\n" +
87
" </xs:sequence>\r\n" +
88
" <xs:attribute name=\"name\" type=\"xs:string\" use=\"optional\"/> \r\n" +
89
" </xs:complexType>\r\n" +
91
" <xs:element name=\"item\" type=\"foo:itemType\" abstract=\"true\"/>\r\n" +
93
"<xs:complexType name=\"itemType\">\r\n" +
94
" <xs:attribute name=\"name\" type=\"xs:string\" use=\"optional\"/> \r\n" +
95
" </xs:complexType>\r\n" +
97
" <xs:element name=\"reference\" substitutionGroup=\"foo:item\">\r\n" +
98
" <xs:complexType>\r\n" +
99
" <xs:complexContent>\r\n" +
100
" <xs:extension base=\"foo:itemType\">\r\n" +
101
" <xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
103
" <xs:element name=\"name\"/>\r\n" +
104
" <xs:element name=\"location\"/> \r\n" +
105
" </xs:choice>\r\n" +
106
" </xs:sequence>\r\n" +
107
" <xs:attribute name=\"description\" type=\"xs:string\"/>\r\n" +
108
" </xs:extension>\r\n" +
109
" </xs:complexContent>\r\n" +
110
" </xs:complexType>\r\n" +
111
" </xs:element>\r\n" +
113
" <xs:element name=\"file\" substitutionGroup=\"foo:item\">\r\n" +
114
" <xs:complexType>\r\n" +
115
" <xs:complexContent>\r\n" +
116
" <xs:extension base=\"foo:itemType\">\r\n" +
117
" <xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
119
" <xs:element name=\"name\"/>\r\n" +
120
" <xs:element name=\"attributes\"/>\r\n" +
121
" </xs:choice>\r\n" +
122
" </xs:sequence>\r\n" +
123
" <xs:attribute name=\"type\" type=\"xs:string\"/>\r\n" +
124
" </xs:extension>\r\n" +
125
" </xs:complexContent>\r\n" +
126
" </xs:complexType>\r\n" +
127
" </xs:element>\r\n" +