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

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/Tests/Schema/GroupRefTestFixture.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 element group refs
 
12
        /// </summary>
 
13
        [TestFixture]
 
14
        public class GroupRefTestFixture : SchemaTestFixtureBase
 
15
        {
 
16
                ICompletionData[] childElements;
 
17
                ICompletionData[] paraAttributes;
 
18
                
 
19
                public override void FixtureInit()
 
20
                {
 
21
                        XmlElementPath path = new XmlElementPath();
 
22
                        
 
23
                        path.Elements.Add(new QualifiedName("html", "http://foo/xhtml"));
 
24
                        path.Elements.Add(new QualifiedName("body", "http://foo/xhtml"));
 
25
                        
 
26
                        childElements = SchemaCompletionData.GetChildElementCompletionData(path);
 
27
                        
 
28
                        path.Elements.Add(new QualifiedName("p", "http://foo/xhtml"));
 
29
                        paraAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
 
30
                }
 
31
                
 
32
                [Test]
 
33
                public void BodyHasFourChildElements()
 
34
                {
 
35
                        Assert.AreEqual(4, childElements.Length, 
 
36
                                        "Should be 4 child elements.");
 
37
                }
 
38
                
 
39
                [Test]
 
40
                public void BodyChildElementForm()
 
41
                {
 
42
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "form"), 
 
43
                                      "Should have a child element called form.");
 
44
                }
 
45
                
 
46
                [Test]
 
47
                public void BodyChildElementPara()
 
48
                {
 
49
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "p"), 
 
50
                                      "Should have a child element called p.");
 
51
                }               
 
52
                
 
53
                [Test]
 
54
                public void BodyChildElementTest()
 
55
                {
 
56
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "test"), 
 
57
                                      "Should have a child element called test.");
 
58
                }               
 
59
                
 
60
                [Test]
 
61
                public void BodyChildElementId()
 
62
                {
 
63
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "id"), 
 
64
                                      "Should have a child element called id.");
 
65
                }               
 
66
                
 
67
                [Test]
 
68
                public void ParaElementHasIdAttribute()
 
69
                {
 
70
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(paraAttributes, "id"), 
 
71
                                      "Should have an attribute called id.");                   
 
72
                }
 
73
                
 
74
                protected override string GetSchema()
 
75
                {
 
76
                        return "<xs:schema version=\"1.0\" xml:lang=\"en\"\r\n" +
 
77
                                "    xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n" +
 
78
                                "    targetNamespace=\"http://foo/xhtml\"\r\n" +
 
79
                                "    xmlns=\"http://foo/xhtml\"\r\n" +
 
80
                                "    elementFormDefault=\"qualified\">\r\n" +
 
81
                                "\r\n" +
 
82
                                "  <xs:element name=\"html\">\r\n" +
 
83
                                "    <xs:complexType>\r\n" +
 
84
                                "      <xs:sequence>\r\n" +
 
85
                                "        <xs:element ref=\"head\"/>\r\n" +
 
86
                                "        <xs:element ref=\"body\"/>\r\n" +
 
87
                                "      </xs:sequence>\r\n" +
 
88
                                "    </xs:complexType>\r\n" +
 
89
                                "  </xs:element>\r\n" +
 
90
                                "\r\n" +
 
91
                                "  <xs:element name=\"head\" type=\"xs:string\"/>\r\n" +
 
92
                                "  <xs:element name=\"body\">\r\n" +
 
93
                                "    <xs:complexType>\r\n" +
 
94
                                "      <xs:sequence>\r\n" +
 
95
                                "        <xs:group ref=\"block\"/>\r\n" +
 
96
                                "        <xs:element name=\"form\"/>\r\n" +
 
97
                                "      </xs:sequence>\r\n" +
 
98
                                "    </xs:complexType>\r\n" +
 
99
                                "  </xs:element>\r\n" +
 
100
                                "\r\n" +
 
101
                                "\r\n" +
 
102
                                "  <xs:group name=\"block\">\r\n" +
 
103
                                "    <xs:choice>\r\n" +
 
104
                                "      <xs:element ref=\"p\"/>\r\n" +
 
105
                                "      <xs:group ref=\"heading\"/>\r\n" +
 
106
                                "    </xs:choice>\r\n" +
 
107
                                "  </xs:group>\r\n" +
 
108
                                "\r\n" +
 
109
                                "  <xs:element name=\"p\">\r\n" +
 
110
                                "    <xs:complexType>\r\n" +
 
111
                                "      <xs:attribute name=\"id\"/>" +
 
112
                                "    </xs:complexType>\r\n" +
 
113
                                "  </xs:element>\r\n" +                         
 
114
                                "\r\n" +
 
115
                                "  <xs:group name=\"heading\">\r\n" +
 
116
                                "    <xs:choice>\r\n" +
 
117
                                "      <xs:element name=\"test\"/>\r\n" +
 
118
                                "      <xs:element name=\"id\"/>\r\n" +
 
119
                                "    </xs:choice>\r\n" +
 
120
                                "  </xs:group>\r\n" +
 
121
                                "\r\n" +
 
122
                                "</xs:schema>";
 
123
                }
 
124
        }
 
125
}