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

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/Tests/Schema/ElementWithAttributeSchemaTestFixture.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
        /// Element that has a single attribute.
 
12
        /// </summary>
 
13
        [TestFixture]
 
14
        public class ElementWithAttributeSchemaTestFixture : SchemaTestFixtureBase
 
15
        {
 
16
                ICompletionData[] attributeCompletionData;
 
17
                string[] attributeName;
 
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
                        attributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path);
 
25
                        attributeName = attributeCompletionData[0].Text;
 
26
                }
 
27
 
 
28
                [Test]
 
29
                public void AttributeCount()
 
30
                {
 
31
                        Assert.AreEqual(1, attributeCompletionData.Length, "Should be one attribute.");
 
32
                }
 
33
                
 
34
                [Test]
 
35
                public void AttributeName()
 
36
                {
 
37
                        Assert.AreEqual("name", attributeName[0], "Attribute name is incorrect.");
 
38
                }               
 
39
                
 
40
                [Test]
 
41
                public void AttributeNameOverloadCount()
 
42
                {
 
43
                        Assert.AreEqual(1, attributeName.Length, "Should only be one item in the array.");
 
44
                }
 
45
                
 
46
                [Test]
 
47
                public void NoAttributesForUnknownElement()
 
48
                {
 
49
                        XmlElementPath path = new XmlElementPath();
 
50
                        path.Elements.Add(new QualifiedName("foobar", "http://www.w3schools.com"));
 
51
                        ICompletionData[] attributes = SchemaCompletionData.GetAttributeCompletionData(path);
 
52
                        
 
53
                        Assert.AreEqual(0, attributes.Length, "Should not find attributes for unknown element.");
 
54
                }
 
55
                
 
56
                protected override string GetSchema()
 
57
                {
 
58
                        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" +
 
59
                                "    <xs:element name=\"note\">\r\n" +
 
60
                                "        <xs:complexType>\r\n" +
 
61
                                "\t<xs:attribute name=\"name\"  type=\"xs:string\"/>\r\n" +
 
62
                                "        </xs:complexType>\r\n" +
 
63
                                "    </xs:element>\r\n" +
 
64
                                "</xs:schema>";
 
65
                }
 
66
        }
 
67
}