2
using MonoDevelop.Ide.CodeCompletion;
3
using MonoDevelop.XmlEditor;
8
namespace MonoDevelop.XmlEditor.Tests.Schema
11
/// Tests complex content extension elements.
14
public class ComplexContentExtensionTestFixture : SchemaTestFixtureBase
16
ICompletionData[] bodyChildElements;
17
ICompletionData[] bodyAttributes;
19
public override void FixtureInit()
21
XmlElementPath path = new XmlElementPath();
22
path.Elements.Add(new QualifiedName("body", "http://www.w3schools.com"));
24
bodyChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
25
bodyAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
29
public void TitleHasNoChildElements()
31
XmlElementPath path = new XmlElementPath();
32
path.Elements.Add(new QualifiedName("body", "http://www.w3schools.com"));
33
path.Elements.Add(new QualifiedName("title", "http://www.w3schools.com"));
35
Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length,
36
"Should be no child elements.");
40
public void TextHasNoChildElements()
42
XmlElementPath path = new XmlElementPath();
43
path.Elements.Add(new QualifiedName("body", "http://www.w3schools.com"));
44
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 BodyHasTwoChildElements()
53
Assert.AreEqual(2, bodyChildElements.Length,
54
"Should be two child elements.");
58
public void BodyChildElementIsText()
60
Assert.IsTrue(SchemaTestFixtureBase.Contains(bodyChildElements, "text"),
61
"Should have a child element called text.");
65
public void BodyChildElementIsTitle()
67
Assert.IsTrue(SchemaTestFixtureBase.Contains(bodyChildElements, "title"),
68
"Should have a child element called title.");
72
public void BodyAttributeCount()
74
Assert.AreEqual(1, bodyAttributes.Length,
75
"Should be one attribute.");
79
public void BodyAttributeName()
81
Assert.IsTrue(SchemaTestFixtureBase.Contains(bodyAttributes, "id"), "Attribute id not found.");
84
protected override string GetSchema()
86
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" +
87
"\t<xs:complexType name=\"Block\">\r\n" +
88
"\t\t<xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
89
"\t\t\t<xs:element name=\"title\" type=\"xs:string\"/>\r\n" +
90
"\t\t\t<xs:element name=\"text\" type=\"xs:string\"/>\r\n" +
91
"\t\t</xs:choice>\r\n" +
92
"\t</xs:complexType>\r\n" +
94
"\t<xs:element name=\"body\">\r\n" +
95
"\t\t<xs:complexType>\r\n" +
96
"\t\t\t<xs:complexContent>\r\n" +
97
"\t\t\t\t<xs:extension base=\"Block\">\r\n" +
98
"\t\t\t\t\t<xs:attribute name=\"id\" type=\"xs:string\"/>\r\n" +
99
"\t\t\t\t</xs:extension>\r\n" +
100
"\t\t\t</xs:complexContent>\r\n" +
101
"\t\t</xs:complexType>\r\n" +
102
"\t</xs:element>\r\n" +