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

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/Tests/FindSchemaObject/ElementTypeWithPrefixSelectedTestFixture.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
using MonoDevelop.XmlEditor.Tests.Schema;
 
9
using MonoDevelop.XmlEditor.Tests.Utils;
 
10
 
 
11
namespace MonoDevelop.XmlEditor.Tests.FindSchemaObject
 
12
{
 
13
        /// <summary>
 
14
        /// Tests that an xs:element/@type="prefix:name" is located in the schema.
 
15
        /// </summary>
 
16
        [TestFixture]
 
17
        public class ElementTypeWithPrefixSelectedTestFixture : SchemaTestFixtureBase
 
18
        {
 
19
                XmlSchemaComplexType schemaComplexType;
 
20
                
 
21
                public override void FixtureInit()
 
22
                {
 
23
                        XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
 
24
                        schemas.Add(SchemaCompletionData);
 
25
                        XmlSchemaCompletionData xsdSchemaCompletionData = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema());
 
26
                        schemas.Add(xsdSchemaCompletionData);
 
27
                        XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xsdSchemaCompletionData, String.Empty, null);
 
28
                        
 
29
                        string xml = GetSchema();
 
30
                        int index = xml.IndexOf("type=\"xs:complexType\"");
 
31
                        index = xml.IndexOf("xs:complexType", index);
 
32
                        schemaComplexType = (XmlSchemaComplexType)XmlEditorView.GetSchemaObjectSelected(xml, index, provider, SchemaCompletionData);
 
33
                }
 
34
                
 
35
                [Test]
 
36
                public void ComplexTypeName()
 
37
                {
 
38
                        Assert.AreEqual("complexType", schemaComplexType.QualifiedName.Name);
 
39
                }
 
40
                
 
41
                [Test]
 
42
                public void ComplexTypeNamespace()
 
43
                {
 
44
                        Assert.AreEqual("http://www.w3.org/2001/XMLSchema", schemaComplexType.QualifiedName.Namespace);
 
45
                }
 
46
                
 
47
                protected override string GetSchema()
 
48
                {
 
49
                        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" +
 
50
                                "\t<xs:element name=\"note\">\r\n" +
 
51
                                "\t\t<xs:complexType> \r\n" +
 
52
                                "\t\t\t<xs:sequence>\r\n" +
 
53
                                "\t\t\t\t<xs:element name=\"text\" type=\"xs:complexType\"/>\r\n" +
 
54
                                "\t\t\t</xs:sequence>\r\n" +
 
55
                                "\t\t</xs:complexType>\r\n" +
 
56
                                "\t</xs:element>\r\n" +
 
57
                                "</xs:schema>";
 
58
                }
 
59
        }
 
60
}