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

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/Tests/Schema/ComplexContentExtensionTestFixture.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 extension elements.
 
12
        /// </summary>
 
13
        [TestFixture]
 
14
        public class ComplexContentExtensionTestFixture : SchemaTestFixtureBase
 
15
        {
 
16
                ICompletionData[] bodyChildElements;
 
17
                ICompletionData[] bodyAttributes;
 
18
                
 
19
                public override void FixtureInit()
 
20
                {
 
21
                        XmlElementPath path = new XmlElementPath();
 
22
                        path.Elements.Add(new QualifiedName("body", "http://www.w3schools.com")); 
 
23
                        
 
24
                        bodyChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
 
25
                        bodyAttributes = SchemaCompletionData.GetAttributeCompletionData(path);
 
26
                }       
 
27
                
 
28
                [Test]
 
29
                public void TitleHasNoChildElements()
 
30
                {
 
31
                        XmlElementPath path = new XmlElementPath();
 
32
                        path.Elements.Add(new QualifiedName("body", "http://www.w3schools.com")); 
 
33
                        path.Elements.Add(new QualifiedName("title", "http://www.w3schools.com")); 
 
34
 
 
35
                        Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length,
 
36
                                        "Should be no child elements.");
 
37
                }
 
38
                
 
39
                [Test]
 
40
                public void TextHasNoChildElements()
 
41
                {
 
42
                        XmlElementPath path = new XmlElementPath();
 
43
                        path.Elements.Add(new QualifiedName("body", "http://www.w3schools.com")); 
 
44
                        path.Elements.Add(new QualifiedName("text", "http://www.w3schools.com")); 
 
45
 
 
46
                        Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length,
 
47
                                        "Should be no child elements.");
 
48
                }               
 
49
                
 
50
                [Test]
 
51
                public void BodyHasTwoChildElements()
 
52
                {
 
53
                        Assert.AreEqual(2, bodyChildElements.Length, 
 
54
                                        "Should be two child elements.");
 
55
                }
 
56
                
 
57
                [Test]
 
58
                public void BodyChildElementIsText()
 
59
                {
 
60
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(bodyChildElements, "text"), 
 
61
                                      "Should have a child element called text.");
 
62
                }
 
63
                
 
64
                [Test]
 
65
                public void BodyChildElementIsTitle()
 
66
                {
 
67
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(bodyChildElements, "title"), 
 
68
                                      "Should have a child element called title.");
 
69
                }               
 
70
                
 
71
                [Test]
 
72
                public void BodyAttributeCount()
 
73
                {
 
74
                        Assert.AreEqual(1, bodyAttributes.Length, 
 
75
                                        "Should be one attribute.");
 
76
                }
 
77
                
 
78
                [Test]
 
79
                public void BodyAttributeName()
 
80
                {
 
81
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(bodyAttributes, "id"), "Attribute id not found.");
 
82
                }
 
83
                
 
84
                protected override string GetSchema()
 
85
                {
 
86
                        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" +
 
87
                                "\t<xs:complexType name=\"Block\">\r\n" +
 
88
                                "\t\t<xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
 
89
                                "\t\t\t<xs:element name=\"title\" type=\"xs:string\"/>\r\n" +
 
90
                                "\t\t\t<xs:element name=\"text\" type=\"xs:string\"/>\r\n" +
 
91
                                "\t\t</xs:choice>\r\n" +
 
92
                                "\t</xs:complexType>\r\n" +
 
93
                                "\r\n" +
 
94
                                "\t<xs:element name=\"body\">\r\n" +
 
95
                                "\t\t<xs:complexType>\r\n" +
 
96
                                "\t\t\t<xs:complexContent>\r\n" +
 
97
                                "\t\t\t\t<xs:extension base=\"Block\">\r\n" +
 
98
                                "\t\t\t\t\t<xs:attribute name=\"id\" type=\"xs:string\"/>\r\n" +
 
99
                                "\t\t\t\t</xs:extension>\r\n" +
 
100
                                "\t\t\t</xs:complexContent>\r\n" +
 
101
                                "\t\t</xs:complexType>\r\n" +
 
102
                                "\t</xs:element>\r\n" +
 
103
                                "</xs:schema>";
 
104
                }
 
105
        }
 
106
}