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

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/Tests/Schema/AbstractElementTestFixture.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.XmlEditor;
 
3
using MonoDevelop.Ide.CodeCompletion;
 
4
using NUnit.Framework;
 
5
using System;
 
6
using System.IO;
 
7
 
 
8
namespace MonoDevelop.XmlEditor.Tests.Schema
 
9
{
 
10
        /// <summary>
 
11
        /// Tests elements that are abstract and require substitution groups.
 
12
        /// </summary>
 
13
        [TestFixture]
 
14
        public class AbstractElementTestFixture : SchemaTestFixtureBase
 
15
        {               
 
16
                ICompletionData[] itemsElementChildren;
 
17
                ICompletionData[] fileElementAttributes;
 
18
                ICompletionData[] fileElementChildren;
 
19
                
 
20
                public override void FixtureInit()
 
21
                {
 
22
                        XmlElementPath path = new XmlElementPath();
 
23
                        
 
24
                        path.Elements.Add(new QualifiedName("project", "http://foo"));
 
25
                        path.Elements.Add(new QualifiedName("items", "http://foo"));
 
26
                        
 
27
                        itemsElementChildren = SchemaCompletionData.GetChildElementCompletionData(path);
 
28
                        
 
29
                        path.Elements.Add(new QualifiedName("file", "http://foo"));
 
30
                        
 
31
                        fileElementAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
 
32
                        fileElementChildren = SchemaCompletionData.GetChildElementCompletionData(path);
 
33
                }
 
34
                
 
35
                [Test]
 
36
                public void ItemsElementHasTwoChildElements()
 
37
                {
 
38
                        Assert.AreEqual(2, itemsElementChildren.Length, 
 
39
                                        "Should be 2 child elements.");
 
40
                }
 
41
                
 
42
                [Test]
 
43
                public void ReferenceElementIsChildOfItemsElement()
 
44
                {
 
45
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(itemsElementChildren, "reference"));
 
46
                }
 
47
                
 
48
                [Test]
 
49
                public void FileElementIsChildOfItemsElement()
 
50
                {
 
51
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(itemsElementChildren, "file"));
 
52
                }
 
53
                
 
54
                [Test]
 
55
                public void FileElementHasAttributeNamedType()
 
56
                {
 
57
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(fileElementAttributes, "type"));
 
58
                }
 
59
                
 
60
                [Test]
 
61
                public void FileElementHasTwoChildElements()
 
62
                {
 
63
                        Assert.AreEqual(2, fileElementChildren.Length, "Should be 2 child elements.");
 
64
                }
 
65
                
 
66
                protected override string GetSchema()
 
67
                {
 
68
                        return "<xs:schema targetNamespace=\"http://foo\" xmlns:foo=\"http://foo\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\">\r\n" +
 
69
                                        "    <xs:element name=\"project\">\r\n" +
 
70
                                        "        <xs:complexType>\r\n" +
 
71
                                        "            <xs:sequence>\r\n" +
 
72
                                        "                <xs:group ref=\"foo:projectItems\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\r\n" +
 
73
                                        "            </xs:sequence>\r\n" +
 
74
                                        "        </xs:complexType>\r\n" +
 
75
                                        "    </xs:element>\r\n" +
 
76
                                        "\r\n" +
 
77
                                        "    <xs:group name=\"projectItems\">\r\n" +
 
78
                                        "        <xs:choice>\r\n" +
 
79
                                        "            <xs:element name=\"items\" type=\"foo:itemGroupType\"/>\r\n" +
 
80
                                        "            <xs:element name=\"message\" type=\"xs:string\"/>\r\n" +
 
81
                                        "        </xs:choice>\r\n" +
 
82
                                        "    </xs:group>\r\n" +
 
83
                                        "\r\n" +
 
84
                                        "    <xs:complexType name=\"itemGroupType\">\r\n" +
 
85
                                        "        <xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
 
86
                                        "            <xs:element ref=\"foo:item\"/>\r\n" +
 
87
                                        "        </xs:sequence>\r\n" +
 
88
                                        "        <xs:attribute name=\"name\" type=\"xs:string\" use=\"optional\"/>            \r\n" +
 
89
                                        "    </xs:complexType>\r\n" +
 
90
                                        "\r\n" +
 
91
                                        "    <xs:element name=\"item\" type=\"foo:itemType\" abstract=\"true\"/>\r\n" +
 
92
                                        "\r\n" +
 
93
                                        "<xs:complexType name=\"itemType\">\r\n" +
 
94
                                        "        <xs:attribute name=\"name\" type=\"xs:string\" use=\"optional\"/>                        \r\n" +
 
95
                                        "    </xs:complexType>\r\n" +
 
96
                                        "\r\n" +
 
97
                                        "    <xs:element name=\"reference\" substitutionGroup=\"foo:item\">\r\n" +
 
98
                                        "        <xs:complexType>\r\n" +
 
99
                                        "            <xs:complexContent>\r\n" +
 
100
                                        "                <xs:extension base=\"foo:itemType\">\r\n" +
 
101
                                        "                    <xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
 
102
                                        "                        <xs:choice>\r\n" +
 
103
                                        "                            <xs:element name=\"name\"/>\r\n" +
 
104
                                        "                            <xs:element name=\"location\"/>                             \r\n" +
 
105
                                        "                        </xs:choice>\r\n" +
 
106
                                        "                    </xs:sequence>\r\n" +
 
107
                                        "                    <xs:attribute name=\"description\" type=\"xs:string\"/>\r\n" +
 
108
                                        "                 </xs:extension>\r\n" +
 
109
                                        "            </xs:complexContent>\r\n" +
 
110
                                        "        </xs:complexType>\r\n" +
 
111
                                        "    </xs:element>\r\n" +
 
112
                                        "\r\n" +
 
113
                                        "    <xs:element name=\"file\" substitutionGroup=\"foo:item\">\r\n" +
 
114
                                        "        <xs:complexType>\r\n" +
 
115
                                        "            <xs:complexContent>\r\n" +
 
116
                                        "                <xs:extension base=\"foo:itemType\">\r\n" +
 
117
                                        "                    <xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
 
118
                                        "                        <xs:choice>\r\n" +
 
119
                                        "                            <xs:element name=\"name\"/>\r\n" +
 
120
                                        "                            <xs:element name=\"attributes\"/>\r\n" +
 
121
                                        "                         </xs:choice>\r\n" +
 
122
                                        "                    </xs:sequence>\r\n" +
 
123
                                        "                    <xs:attribute name=\"type\" type=\"xs:string\"/>\r\n" +
 
124
                                        "                </xs:extension>\r\n" +
 
125
                                        "            </xs:complexContent>\r\n" +
 
126
                                        "        </xs:complexType>\r\n" +
 
127
                                        "    </xs:element>\r\n" +
 
128
                                        "</xs:schema>";
 
129
                }
 
130
        }
 
131
}