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 is located in the schema.
17
public class ElementReferenceSelectedTestFixture : SchemaTestFixtureBase
19
XmlSchemaAttribute schemaAttribute;
20
XmlSchemaElement referencedSchemaElement;
22
public override void FixtureInit()
24
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
25
schemas.Add(SchemaCompletionData);
26
XmlSchemaCompletionData xsdSchemaCompletionData = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema());
27
schemas.Add(xsdSchemaCompletionData);
28
XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xsdSchemaCompletionData, String.Empty, null);
30
string xml = GetSchema();
31
schemaAttribute = (XmlSchemaAttribute)XmlEditorView.GetSchemaObjectSelected(xml, xml.IndexOf("ref=\"name"), provider, SchemaCompletionData);
33
int index = xml.IndexOf("ref=\"name");
34
index = xml.IndexOf('n', index);
35
referencedSchemaElement = (XmlSchemaElement)XmlEditorView.GetSchemaObjectSelected(xml, index, provider, SchemaCompletionData);
39
public void AttributeName()
41
Assert.AreEqual("ref", schemaAttribute.QualifiedName.Name);
45
public void ReferencedElementName()
47
Assert.AreEqual("name", referencedSchemaElement.QualifiedName.Name);
50
protected override string GetSchema()
52
return "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\">\r\n" +
54
"<!-- definition of simple elements -->\r\n" +
55
"<xs:element name=\"name\" type=\"xs:string\"/>\r\n" +
56
"<xs:element name=\"address\" type=\"xs:string\"/>\r\n" +
58
"<!-- definition of complex elements -->\r\n" +
59
"<xs:element name=\"shipto\">\r\n" +
60
" <xs:complexType>\r\n" +
61
" <xs:sequence>\r\n" +
62
" <xs:element ref=\"name\"/>\r\n" +
63
" <xs:element ref=\"address\"/>\r\n" +
64
" </xs:sequence>\r\n" +
65
" <xs:attribute name=\"address\"/>\r\n" +
66
" </xs:complexType>\r\n" +
69
"<xs:element name=\"shiporder\">\r\n" +
70
" <xs:complexType>\r\n" +
71
" <xs:sequence>\r\n" +
72
" <xs:element ref=\"shipto\"/>\r\n" +
73
" </xs:sequence>\r\n" +
74
" <xs:attribute name=\"id\"/>\r\n" +
75
" </xs:complexType>\r\n" +