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

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/Tests/Schema/NestedChoiceTestFixture.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 that nested schema choice elements are handled.
 
12
        /// This happens in the NAnt schema 0.85.
 
13
        /// </summary>
 
14
        [TestFixture]
 
15
        public class NestedChoiceTestFixture : SchemaTestFixtureBase
 
16
        {
 
17
                ICompletionData[] noteChildElements;
 
18
                ICompletionData[] titleChildElements;
 
19
                
 
20
                public override void FixtureInit()
 
21
                {
 
22
                        // Get note child elements.
 
23
                        XmlElementPath path = new XmlElementPath();
 
24
                        path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
 
25
                        
 
26
                        noteChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
 
27
                
 
28
                        // Get title child elements.
 
29
                        path.Elements.Add(new QualifiedName("title", "http://www.w3schools.com"));
 
30
                        titleChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
 
31
                }
 
32
                
 
33
                [Test]
 
34
                public void TitleHasTwoChildElements()
 
35
                {
 
36
                        Assert.AreEqual(2, titleChildElements.Length, 
 
37
                                        "Should be 2 child elements.");
 
38
                }
 
39
                
 
40
                [Test]
 
41
                public void TextHasNoChildElements()
 
42
                {
 
43
                        XmlElementPath path = new XmlElementPath();
 
44
                        path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
 
45
                        path.Elements.Add(new QualifiedName("text", "http://www.w3schools.com"));
 
46
                        Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length, 
 
47
                                        "Should be no child elements.");
 
48
                }               
 
49
                
 
50
                [Test]
 
51
                public void NoteHasTwoChildElements()
 
52
                {
 
53
                        Assert.AreEqual(2, noteChildElements.Length, 
 
54
                                        "Should be two child elements.");
 
55
                }
 
56
                
 
57
                [Test]
 
58
                public void NoteChildElementIsText()
 
59
                {
 
60
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "text"), 
 
61
                                      "Should have a child element called text.");
 
62
                }
 
63
                
 
64
                [Test]
 
65
                public void NoteChildElementIsTitle()
 
66
                {
 
67
                        Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "title"), 
 
68
                                      "Should have a child element called title.");
 
69
                }               
 
70
                
 
71
                protected override string GetSchema()
 
72
                {
 
73
                        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" +
 
74
                                "\t<xs:element name=\"note\">\r\n" +
 
75
                                "\t\t<xs:complexType> \r\n" +
 
76
                                "\t\t\t<xs:choice>\r\n" +
 
77
                                "\t\t\t\t<xs:element ref=\"title\"/>\r\n" +
 
78
                                "\t\t\t\t<xs:element name=\"text\" type=\"xs:string\"/>\r\n" +
 
79
                                "\t\t\t</xs:choice>\r\n" +
 
80
                                "\t\t</xs:complexType>\r\n" +
 
81
                                "\t</xs:element>\r\n" +
 
82
                                "\t<xs:element name=\"title\">\r\n" +
 
83
                                "\t\t<xs:complexType> \r\n" +
 
84
                                "\t\t\t<xs:choice>\r\n" +
 
85
                                "\t\t\t\t<xs:element name=\"foo\" type=\"xs:string\"/>\r\n" +
 
86
                                "\t\t\t\t<xs:element name=\"bar\" type=\"xs:string\"/>\r\n" +
 
87
                                "\t\t\t</xs:choice>\r\n" +
 
88
                                "\t\t</xs:complexType>\r\n" +
 
89
                                "\t</xs:element>\r\n" +                         
 
90
                                "</xs:schema>";
 
91
                }
 
92
        }
 
93
}