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 ChoiceTestFixture : SchemaTestFixtureBase
17
ICompletionData[] noteChildElements;
19
public override void FixtureInit()
21
XmlElementPath path = new XmlElementPath();
22
path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
24
noteChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
28
public void TitleHasNoChildElements()
30
XmlElementPath path = new XmlElementPath();
31
path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
32
path.Elements.Add(new QualifiedName("title", "http://www.w3schools.com"));
33
Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length,
34
"Should be no child elements.");
38
public void TextHasNoChildElements()
40
XmlElementPath path = new XmlElementPath();
41
path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
42
path.Elements.Add(new QualifiedName("text", "http://www.w3schools.com"));
43
Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length,
44
"Should be no child elements.");
48
public void NoteHasTwoChildElements()
50
Assert.AreEqual(2, noteChildElements.Length,
51
"Should be two child elements.");
55
public void NoteChildElementIsText()
57
Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "text"),
58
"Should have a child element called text.");
62
public void NoteChildElementIsTitle()
64
Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "title"),
65
"Should have a child element called title.");
68
protected override string GetSchema()
70
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" +
71
"\t<xs:element name=\"note\">\r\n" +
72
"\t\t<xs:complexType> \r\n" +
73
"\t\t\t<xs:choice>\r\n" +
74
"\t\t\t\t<xs:element name=\"title\" type=\"xs:string\"/>\r\n" +
75
"\t\t\t\t<xs:element name=\"text\" type=\"xs:string\"/>\r\n" +
76
"\t\t\t</xs:choice>\r\n" +
77
"\t\t</xs:complexType>\r\n" +
78
"\t</xs:element>\r\n" +