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

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/Tests/Schema/FindAttributeFromComplexTypeTestFixture.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
using System.Xml.Schema;
 
8
 
 
9
namespace MonoDevelop.XmlEditor.Tests.Schema
 
10
{
 
11
        /// <summary>
 
12
        /// Element that has a single attribute.
 
13
        /// </summary>
 
14
        [TestFixture]
 
15
        public class FindAttributeFromComplexTypeFixture : SchemaTestFixtureBase
 
16
        {
 
17
                XmlSchemaAttribute attribute;
 
18
                XmlSchemaAttribute missingAttribute;
 
19
                
 
20
                public override void FixtureInit()
 
21
                {
 
22
                        XmlElementPath path = new XmlElementPath();
 
23
                        path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
 
24
                        
 
25
                        XmlSchemaElement element = SchemaCompletionData.FindElement(path);
 
26
                        attribute = SchemaCompletionData.FindAttribute(element, "name");
 
27
                        missingAttribute = SchemaCompletionData.FindAttribute(element, "missing");
 
28
                }
 
29
                
 
30
                [Test]
 
31
                public void AttributeFound()
 
32
                {
 
33
                        Assert.IsNotNull(attribute);
 
34
                }               
 
35
                
 
36
                [Test]
 
37
                public void CannotFindUnknownAttribute()
 
38
                {
 
39
                        Assert.IsNull(missingAttribute);
 
40
                }
 
41
                
 
42
                protected override string GetSchema()
 
43
                {
 
44
                        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" +
 
45
                                "    <xs:element name=\"note\">\r\n" +
 
46
                                "        <xs:complexType>\r\n" +
 
47
                                "            <xs:attribute name=\"name\"  type=\"xs:string\"/>\r\n" +
 
48
                                "        </xs:complexType>\r\n" +
 
49
                                "    </xs:element>\r\n" +
 
50
                                "</xs:schema>";
 
51
                }
 
52
        }
 
53
}