~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/Tests/Schema/AttributeRefTestFixture.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
using MonoDevelop.Ide.CodeCompletion;
 
3
using MonoDevelop.XmlEditor;
 
4
using NUnit.Framework;
 
5
using System;
 
6
using System.IO;
 
7
 
 
8
namespace MonoDevelop.XmlEditor.Tests.Schema
 
9
{
 
10
        /// <summary>
 
11
        /// Tests attribute refs
 
12
        /// </summary>
 
13
        [TestFixture]
 
14
        public class AttributeRefTestFixture : SchemaTestFixtureBase
 
15
        {
 
16
                ICompletionData[] attributes;
 
17
                
 
18
                public override void FixtureInit()
 
19
                {
 
20
                        XmlElementPath path = new XmlElementPath();
 
21
                        path.Elements.Add(new QualifiedName("html", "http://foo/xhtml"));
 
22
                        attributes = SchemaCompletionData.GetAttributeCompletionData(path);
 
23
                }
 
24
                
 
25
                [Test]
 
26
                public void HtmlAttributeCount()
 
27
                {
 
28
                        Assert.AreEqual(4, attributes.Length, 
 
29
                                        "Should be 4 attributes.");
 
30
                }
 
31
                
 
32
                [Test]
 
33
                public void HtmlLangAttribute()
 
34
                {
 
35
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "lang"), "Attribute lang not found.");
 
36
                }
 
37
                
 
38
                [Test]
 
39
                public void HtmlIdAttribute()
 
40
                {
 
41
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "id"), "Attribute id not found.");
 
42
                }               
 
43
                
 
44
                [Test]
 
45
                public void HtmlDirAttribute()
 
46
                {
 
47
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "dir"), "Attribute dir not found.");
 
48
                }                       
 
49
                
 
50
                [Test]
 
51
                public void HtmlXmlLangAttribute()
 
52
                {
 
53
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "xml:lang"), "Attribute xml:lang not found.");
 
54
                }                               
 
55
                
 
56
                protected override string GetSchema()
 
57
                {
 
58
                        return "<xs:schema version=\"1.0\" xml:lang=\"en\"\r\n" +
 
59
                                        "    xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n" +
 
60
                                        "    targetNamespace=\"http://foo/xhtml\"\r\n" +
 
61
                                        "    xmlns=\"http://foo/xhtml\"\r\n" +
 
62
                                        "    elementFormDefault=\"qualified\">\r\n" +
 
63
                                        "  <xs:element name=\"html\">\r\n" +
 
64
                                        "    <xs:complexType>\r\n" +
 
65
                                        "      <xs:sequence>\r\n" +
 
66
                                        "        <xs:element ref=\"head\"/>\r\n" +
 
67
                                        "        <xs:element ref=\"body\"/>\r\n" +
 
68
                                        "      </xs:sequence>\r\n" +
 
69
                                        "      <xs:attributeGroup ref=\"i18n\"/>\r\n" +
 
70
                                        "      <xs:attribute name=\"id\" type=\"xs:ID\"/>\r\n" +
 
71
                                        "    </xs:complexType>\r\n" +
 
72
                                        "  </xs:element>\r\n" +
 
73
                                        "\r\n" +
 
74
                                        "  <xs:element name=\"head\" type=\"xs:string\"/>\r\n" +
 
75
                                        "  <xs:element name=\"body\" type=\"xs:string\"/>\r\n" +
 
76
                                        "\r\n" +
 
77
                                        "  <xs:attributeGroup name=\"i18n\">\r\n" +
 
78
                                        "    <xs:annotation>\r\n" +
 
79
                                        "      <xs:documentation>\r\n" +
 
80
                                        "      internationalization attributes\r\n" +
 
81
                                        "      lang        language code (backwards compatible)\r\n" +
 
82
                                        "      xml:lang    language code (as per XML 1.0 spec)\r\n" +
 
83
                                        "      dir         direction for weak/neutral text\r\n" +
 
84
                                        "      </xs:documentation>\r\n" +
 
85
                                        "    </xs:annotation>\r\n" +
 
86
                                        "    <xs:attribute name=\"lang\" type=\"LanguageCode\"/>\r\n" +
 
87
                                        "    <xs:attribute ref=\"xml:lang\"/>\r\n" +
 
88
                                        "\r\n" +
 
89
                                        "    <xs:attribute name=\"dir\">\r\n" +
 
90
                                        "      <xs:simpleType>\r\n" +
 
91
                                        "        <xs:restriction base=\"xs:token\">\r\n" +
 
92
                                        "          <xs:enumeration value=\"ltr\"/>\r\n" +
 
93
                                        "          <xs:enumeration value=\"rtl\"/>\r\n" +
 
94
                                        "        </xs:restriction>\r\n" +
 
95
                                        "      </xs:simpleType>\r\n" +
 
96
                                        "    </xs:attribute>\r\n" +
 
97
                                        "  </xs:attributeGroup>\r\n" +
 
98
                                        "</xs:schema>";
 
99
                }
 
100
        }
 
101
}