1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
using System.Xml.Schema;
using MonoDevelop.XmlEditor.Tests.Schema;
using MonoDevelop.XmlEditor.Tests.Utils;
namespace MonoDevelop.XmlEditor.Tests.FindSchemaObject
{
/// <summary>
/// Tests that an xs:element/@type="prefix:name" is located in the schema.
/// </summary>
[TestFixture]
public class ElementTypeWithPrefixSelectedTestFixture : SchemaTestFixtureBase
{
XmlSchemaComplexType schemaComplexType;
public override void FixtureInit()
{
XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
schemas.Add(SchemaCompletionData);
XmlSchemaCompletionData xsdSchemaCompletionData = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema());
schemas.Add(xsdSchemaCompletionData);
XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xsdSchemaCompletionData, String.Empty, null);
string xml = GetSchema();
int index = xml.IndexOf("type=\"xs:complexType\"");
index = xml.IndexOf("xs:complexType", index);
schemaComplexType = (XmlSchemaComplexType)XmlEditorView.GetSchemaObjectSelected(xml, index, provider, SchemaCompletionData);
}
[Test]
public void ComplexTypeName()
{
Assert.AreEqual("complexType", schemaComplexType.QualifiedName.Name);
}
[Test]
public void ComplexTypeNamespace()
{
Assert.AreEqual("http://www.w3.org/2001/XMLSchema", schemaComplexType.QualifiedName.Namespace);
}
protected override string GetSchema()
{
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" +
"\t<xs:element name=\"note\">\r\n" +
"\t\t<xs:complexType> \r\n" +
"\t\t\t<xs:sequence>\r\n" +
"\t\t\t\t<xs:element name=\"text\" type=\"xs:complexType\"/>\r\n" +
"\t\t\t</xs:sequence>\r\n" +
"\t\t</xs:complexType>\r\n" +
"\t</xs:element>\r\n" +
"</xs:schema>";
}
}
}
|