blob: 5929d390824270f75c6c23b93d197c8ddeb225b8 (
plain)
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
|
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.Xml.Completion;
using NUnit.Framework;
namespace MonoDevelop.Xml.Tests.Schema
{
/// <summary>
/// Element that has a single attribute.
/// </summary>
[TestFixture]
public class ElementWithAttributeSchemaTestFixture : SchemaTestFixtureBase
{
CompletionDataList attributeCompletionData;
string attributeName;
public override void FixtureInit()
{
XmlElementPath path = new XmlElementPath();
path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
attributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path);
attributeName = attributeCompletionData[0].DisplayText;
}
[Test]
public void AttributeCount()
{
Assert.AreEqual(1, attributeCompletionData.Count, "Should be one attribute.");
}
[Test]
public void AttributeName()
{
Assert.AreEqual("name", attributeName, "Attribute name is incorrect.");
}
[Test]
public void NoAttributesForUnknownElement()
{
XmlElementPath path = new XmlElementPath();
path.Elements.Add(new QualifiedName("foobar", "http://www.w3schools.com"));
CompletionDataList attributes = SchemaCompletionData.GetAttributeCompletionData(path);
Assert.AreEqual(0, attributes.Count, "Should not find attributes for unknown element.");
}
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" +
" <xs:element name=\"note\">\r\n" +
" <xs:complexType>\r\n" +
"\t<xs:attribute name=\"name\" type=\"xs:string\"/>\r\n" +
" </xs:complexType>\r\n" +
" </xs:element>\r\n" +
"</xs:schema>";
}
}
}
|