1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
4
using ICSharpCode.XmlEditor;
8
using System.Xml.Schema;
9
using XmlEditor.Tests.Schema;
10
using XmlEditor.Tests.Utils;
12
namespace XmlEditor.Tests.FindSchemaObject
15
/// Tests that a xs:attribute/@type can be located in the schema.
18
public class AttributeTypeSelectedTestFixture : SchemaTestFixtureBase
20
XmlSchemaSimpleType schemaSimpleType;
22
public override void FixtureInit()
24
XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
25
schemas.Add(SchemaCompletion);
26
XmlSchemaCompletion xsdSchemaCompletionData = new XmlSchemaCompletion(ResourceManager.ReadXsdSchema());
27
schemas.Add(xsdSchemaCompletionData);
29
string xml = GetSchema();
30
int index = xml.IndexOf("type=\"dir\"/>");
31
index = xml.IndexOf("dir", index);
32
XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
33
schemaSimpleType = (XmlSchemaSimpleType)schemaDefinition.GetSelectedSchemaObject(xml, index);
37
public void SimpleTypeName()
39
Assert.AreEqual("dir", schemaSimpleType.QualifiedName.Name);
42
protected override string GetSchema()
44
return "<xs:schema version=\"1.0\" xml:lang=\"en\"\r\n" +
45
" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n" +
46
" targetNamespace=\"http://foo/xhtml\"\r\n" +
47
" xmlns=\"http://foo/xhtml\"\r\n" +
48
" elementFormDefault=\"qualified\">\r\n" +
49
" <xs:element name=\"html\">\r\n" +
50
" <xs:complexType>\r\n" +
51
" <xs:sequence>\r\n" +
52
" <xs:element ref=\"head\"/>\r\n" +
53
" <xs:element ref=\"body\"/>\r\n" +
54
" </xs:sequence>\r\n" +
55
" <xs:attributeGroup ref=\"i18n\"/>\r\n" +
56
" <xs:attribute name=\"id\" type=\"dir\"/>\r\n" +
57
" </xs:complexType>\r\n" +
58
" </xs:element>\r\n" +
60
" <xs:element name=\"head\" type=\"xs:string\"/>\r\n" +
61
" <xs:element name=\"body\" type=\"xs:string\"/>\r\n" +
63
" <xs:simpleType name=\"dir\">\r\n" +
64
" <xs:restriction base=\"xs:token\">\r\n" +
65
" <xs:enumeration value=\"ltr\"/>\r\n" +
66
" <xs:enumeration value=\"rtl\"/>\r\n" +
67
" </xs:restriction>\r\n" +
68
" </xs:simpleType>\r\n" +