2
using MonoDevelop.Ide.CodeCompletion;
3
using MonoDevelop.XmlEditor;
7
using System.Xml.Schema;
8
using MonoDevelop.XmlEditor.Tests.Schema;
9
using MonoDevelop.XmlEditor.Tests.Utils;
11
namespace MonoDevelop.XmlEditor.Tests.FindSchemaObject
14
/// Tests that an xs:element/@ref='prefix:name' is located in the schema.
17
public class ElementReferenceWithPrefixSelectedTestFixture : SchemaTestFixtureBase
19
XmlSchemaElement referencedSchemaElement;
21
public override void FixtureInit()
23
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
24
schemas.Add(SchemaCompletionData);
25
XmlSchemaCompletionData xsdSchemaCompletionData = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema());
26
schemas.Add(xsdSchemaCompletionData);
27
XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xsdSchemaCompletionData, String.Empty, null);
29
string xml = GetSchema();
31
int index = xml.IndexOf("ref=\"xs:list");
32
index = xml.IndexOf("xs", index);
33
referencedSchemaElement = (XmlSchemaElement)XmlEditorView.GetSchemaObjectSelected(xml, index, provider, SchemaCompletionData);
37
public void ReferencedElementName()
39
Assert.AreEqual("list", referencedSchemaElement.QualifiedName.Name);
43
public void ReferencedElementNamespace()
45
Assert.AreEqual("http://www.w3.org/2001/XMLSchema", referencedSchemaElement.QualifiedName.Namespace);
48
protected override string GetSchema()
50
return "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\">\r\n" +
52
"<!-- definition of simple elements -->\r\n" +
53
"<xs:element name=\"name\" type=\"xs:string\"/>\r\n" +
54
"<xs:element name=\"address\" type=\"xs:string\"/>\r\n" +
56
"<!-- definition of complex elements -->\r\n" +
57
"<xs:element name=\"shipto\">\r\n" +
58
" <xs:complexType>\r\n" +
59
" <xs:sequence>\r\n" +
60
" <xs:element ref=\"name\"/>\r\n" +
61
" <xs:element ref=\"xs:list\"/>\r\n" +
62
" </xs:sequence>\r\n" +
63
" <xs:attribute name=\"address\"/>\r\n" +
64
" </xs:complexType>\r\n" +
67
"<xs:element name=\"shiporder\">\r\n" +
68
" <xs:complexType>\r\n" +
69
" <xs:sequence>\r\n" +
70
" <xs:element ref=\"shipto\"/>\r\n" +
71
" </xs:sequence>\r\n" +
72
" <xs:attribute name=\"id\"/>\r\n" +
73
" </xs:complexType>\r\n" +