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

« back to all changes in this revision

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