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

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/Tests/Schema/RestrictionElementTestFixture.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 complex content restriction elements.
 
12
        /// </summary>
 
13
        [TestFixture]
 
14
        public class RestrictionElementTestFixture : SchemaTestFixtureBase
 
15
        {
 
16
                ICompletionData[] childElements;
 
17
                ICompletionData[] attributes;
 
18
                ICompletionData[] annotationChildElements;
 
19
                ICompletionData[] choiceChildElements;
 
20
                
 
21
                public override void FixtureInit()
 
22
                {                       
 
23
                        XmlElementPath path = new XmlElementPath();
 
24
                        path.Elements.Add(new QualifiedName("group", "http://www.w3.org/2001/XMLSchema"));
 
25
                        childElements = SchemaCompletionData.GetChildElementCompletionData(path);
 
26
                        attributes = SchemaCompletionData.GetAttributeCompletionData(path);
 
27
                
 
28
                        // Get annotation child elements.
 
29
                        path.Elements.Add(new QualifiedName("annotation", "http://www.w3.org/2001/XMLSchema"));
 
30
                        annotationChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
 
31
                        
 
32
                        // Get choice child elements.
 
33
                        path.Elements.RemoveLast();
 
34
                        path.Elements.Add(new QualifiedName("choice", "http://www.w3.org/2001/XMLSchema"));
 
35
                        choiceChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
 
36
                }
 
37
 
 
38
                [Test]
 
39
                public void GroupChildElementIsAnnotation()
 
40
                {
 
41
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "annotation"), 
 
42
                                      "Should have a child element called annotation.");
 
43
                }
 
44
                
 
45
                [Test]
 
46
                public void GroupChildElementIsChoice()
 
47
                {
 
48
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "choice"), 
 
49
                                      "Should have a child element called choice.");
 
50
                }               
 
51
                
 
52
                [Test]
 
53
                public void GroupChildElementIsSequence()
 
54
                {
 
55
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "sequence"), 
 
56
                                      "Should have a child element called sequence.");
 
57
                }               
 
58
                
 
59
                [Test]
 
60
                public void GroupAttributeIsName()
 
61
                {
 
62
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "name"),
 
63
                                      "Should have an attribute called name.");                 
 
64
                }
 
65
                
 
66
                [Test]
 
67
                public void AnnotationChildElementIsAppInfo()
 
68
                {
 
69
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(annotationChildElements, "appinfo"), 
 
70
                                      "Should have a child element called appinfo.");
 
71
                }       
 
72
                
 
73
                [Test]
 
74
                public void AnnotationChildElementIsDocumentation()
 
75
                {
 
76
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(annotationChildElements, "documentation"), 
 
77
                                      "Should have a child element called appinfo.");
 
78
                }       
 
79
                
 
80
                [Test]
 
81
                public void ChoiceChildElementIsSequence()
 
82
                {
 
83
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(choiceChildElements, "element"), 
 
84
                                      "Should have a child element called element.");
 
85
                }       
 
86
                
 
87
                protected override string GetSchema()
 
88
                {
 
89
                        return "<xs:schema targetNamespace=\"http://www.w3.org/2001/XMLSchema\" blockDefault=\"#all\" elementFormDefault=\"qualified\" version=\"1.0\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xml:lang=\"EN\" xmlns:hfp=\"http://www.w3.org/2001/XMLSchema-hasFacetAndProperty\">\r\n" +
 
90
                                        "\r\n" +
 
91
                                        " <xs:element name=\"group\" type=\"xs:namedGroup\" id=\"group\">\r\n" +
 
92
                                        " </xs:element>\r\n" +
 
93
                                        "\r\n" +
 
94
                                        " <xs:element name=\"annotation\" id=\"annotation\">\r\n" +
 
95
                                        "   <xs:complexType>\r\n" +
 
96
                                        "      <xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
 
97
                                        "       <xs:element name=\"appinfo\"/>\r\n" +
 
98
                                        "       <xs:element name=\"documentation\"/>\r\n" +
 
99
                                        "      </xs:choice>\r\n" +
 
100
                                        "      <xs:attribute name=\"id\" type=\"xs:ID\"/>\r\n" +
 
101
                                        "   </xs:complexType>\r\n" +
 
102
                                        " </xs:element>\r\n" +
 
103
                                        "\r\n" +
 
104
                                        "\r\n" +
 
105
                                        " <xs:complexType name=\"namedGroup\">\r\n" +
 
106
                                        "  <xs:complexContent>\r\n" +
 
107
                                        "   <xs:restriction base=\"xs:realGroup\">\r\n" +
 
108
                                        "    <xs:sequence>\r\n" +
 
109
                                        "     <xs:element ref=\"xs:annotation\" minOccurs=\"0\"/>\r\n" +
 
110
                                        "     <xs:choice minOccurs=\"1\" maxOccurs=\"1\">\r\n" +
 
111
                                        "      <xs:element ref=\"xs:choice\"/>\r\n" +
 
112
                                        "      <xs:element name=\"sequence\"/>\r\n" +
 
113
                                        "     </xs:choice>\r\n" +
 
114
                                        "    </xs:sequence>\r\n" +
 
115
                                        "    <xs:attribute name=\"name\" use=\"required\" type=\"xs:NCName\"/>\r\n" +
 
116
                                        "    <xs:attribute name=\"ref\" use=\"prohibited\"/>\r\n" +
 
117
                                        "    <xs:attribute name=\"minOccurs\" use=\"prohibited\"/>\r\n" +
 
118
                                        "    <xs:attribute name=\"maxOccurs\" use=\"prohibited\"/>\r\n" +
 
119
                                        "    <xs:anyAttribute namespace=\"##other\" processContents=\"lax\"/>\r\n" +
 
120
                                        "   </xs:restriction>\r\n" +
 
121
                                        "  </xs:complexContent>\r\n" +
 
122
                                        " </xs:complexType>\r\n" +
 
123
                                        "\r\n" +
 
124
                                        " <xs:complexType name=\"realGroup\">\r\n" +
 
125
                                        "    <xs:sequence>\r\n" +
 
126
                                        "     <xs:element ref=\"xs:annotation\" minOccurs=\"0\"/>\r\n" +
 
127
                                        "     <xs:choice minOccurs=\"0\" maxOccurs=\"1\">\r\n" +
 
128
                                        "      <xs:element name=\"all\"/>\r\n" +
 
129
                                        "      <xs:element ref=\"xs:choice\"/>\r\n" +
 
130
                                        "      <xs:element name=\"sequence\"/>\r\n" +
 
131
                                        "     </xs:choice>\r\n" +
 
132
                                        "    </xs:sequence>\r\n" +
 
133
                                        "    <xs:anyAttribute namespace=\"##other\" processContents=\"lax\"/>\r\n" +
 
134
                                        " </xs:complexType>\r\n" +
 
135
                                        "\r\n" +
 
136
                                        " <xs:element name=\"choice\" id=\"choice\">\r\n" +
 
137
                                        "   <xs:complexType>\r\n" +
 
138
                                        "     <xs:choice minOccurs=\"0\" maxOccurs=\"1\">\r\n" +
 
139
                                        "       <xs:element name=\"element\"/>\r\n" +
 
140
                                    "       <xs:element name=\"sequence\"/>\r\n" +
 
141
                                        "     </xs:choice>\r\n" +                                       
 
142
                                        "   </xs:complexType>\r\n" +
 
143
                                        " </xs:element>\r\n" +
 
144
                                        "</xs:schema>";
 
145
                }
 
146
        }
 
147
}