From 43a18fe66aa43a50659447f3ae5f6cdc68b4b0c1 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Wed, 24 Aug 2005 19:55:27 +0000 Subject: [PATCH] Added xml editor tests from Fidalgo branch. The XmlSchemaCompletionData class is now using the XmlSchemaAttribute's AttributeSchemaType property instead of the obsolete AttributeType which was causing a few of the attribute value tests to fail. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@435 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/XmlSchemaCompletionData.cs | 11 +- .../XmlEditor/Project/XmlEditor.csproj | 2 +- ...tributeGroupRefSchemaIncludeTestFixture.cs | 48 ++++++ .../TwoElementSchemaIncludeTestFixture.cs | 48 ++++++ .../Test/Schema.Uri/GetUriTestFixture.cs | 46 ++++++ .../Test/Schema/AbstractElementTestFixture.cs | 137 ++++++++++++++++++ .../Schema/AttributeAnnotationTestFixture.cs | 15 +- .../Schema/AttributeGroupRefTestFixture.cs | 21 +-- .../Test/Schema/AttributeRefTestFixture.cs | 18 +-- .../AttributeValueAnnotationTestFixture.cs | 15 +- .../ChildElementAttributesTestFixture.cs | 13 +- .../Test/Schema/ChoiceTestFixture.cs | 21 +-- .../ComplexContentExtensionTestFixture.cs | 23 ++- .../Schema/DuplicateElementTestFixture.cs | 15 +- .../Schema/ElementAnnotationTestFixture.cs | 12 +- .../Schema/ElementRefAnnotationTestFixture.cs | 13 +- .../ElementWithAttributeSchemaTestFixture.cs | 15 +- .../Schema/EnumAttributeValueTestFixture.cs | 14 +- .../Schema/ExtensionElementTestFixture.cs | 40 +++-- .../Schema/GroupRefCompositorTestFixture.cs | 19 +-- .../Test/Schema/GroupRefTestFixture.cs | 22 ++- .../Schema/NamespaceCompletionTestFixture.cs | 6 +- .../NestedAttributeGroupRefTestFixture.cs | 25 ++-- .../Test/Schema/NestedChoiceTestFixture.cs | 19 +-- .../Schema/NestedElementSchemaTestFixture.cs | 15 +- .../Test/Schema/NestedSequenceTestFixture.cs | 19 +-- .../Schema/ReferencedElementsTestFixture.cs | 33 ++--- .../Schema/RestrictionElementTestFixture.cs | 33 ++--- .../Test/Schema/SchemaTestFixtureBase.cs | 122 +++++++++++++++- .../Test/Schema/SequencedChoiceTestFixture.cs | 19 +-- .../SimpleContentWithAttributeTestFixture.cs | 13 +- .../Schema/SingleElementSchemaTestFixture.cs | 15 +- .../Schema/TwoElementSchemaTestFixture.cs | 25 ++-- .../Test/Schema/XsdSchemaTestFixture.cs | 30 ++-- .../XmlEditor/Test/Utils/ResourceManager.cs | 4 +- .../Utils/SchemaIncludeTestFixtureHelper.cs | 90 ++++++++++++ .../XmlEditor/Test/XmlEditor.Tests.csproj | 5 + .../DisplayBindings/XmlEditor/XmlEditor.sln | 2 +- 38 files changed, 705 insertions(+), 338 deletions(-) create mode 100644 src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Includes/AttributeGroupRefSchemaIncludeTestFixture.cs create mode 100644 src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Includes/TwoElementSchemaIncludeTestFixture.cs create mode 100644 src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Uri/GetUriTestFixture.cs create mode 100644 src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AbstractElementTestFixture.cs create mode 100644 src/AddIns/DisplayBindings/XmlEditor/Test/Utils/SchemaIncludeTestFixtureHelper.cs diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionData.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionData.cs index 39bc74043b..f4ff9a7a20 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionData.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionData.cs @@ -998,15 +998,14 @@ namespace ICSharpCode.XmlEditor if (simpleTypeRestriction != null) { data.AddRange(GetAttributeValueCompletionData(simpleTypeRestriction)); } - } else if (attribute.AttributeType != null) { - XmlSchemaSimpleType simpleType = attribute.AttributeType as XmlSchemaSimpleType; - XmlSchemaDatatype dataType = attribute.AttributeType as XmlSchemaDatatype; + } else if (attribute.AttributeSchemaType != null) { + XmlSchemaSimpleType simpleType = attribute.AttributeSchemaType as XmlSchemaSimpleType; if (simpleType != null) { - data.AddRange(GetAttributeValueCompletionData(simpleType)); - } else if (dataType != null) { - if (dataType.ValueType == typeof(bool)) { + if (simpleType.Name == "boolean") { data.AddRange(GetBooleanAttributeValueCompletionData()); + } else { + data.AddRange(GetAttributeValueCompletionData(simpleType)); } } } diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.csproj b/src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.csproj index 95fb4c504f..ce6ddda5be 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.csproj +++ b/src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.csproj @@ -3,7 +3,7 @@ Debug AnyCPU 2.0 - {6B717BD1-CD5E-498C-A42E-9E6A4584DC48} + {63B6CA43-58D0-4BF0-9D4F-1ABE4009E488} ICSharpCode.XmlEditor XmlEditor Library diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Includes/AttributeGroupRefSchemaIncludeTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Includes/AttributeGroupRefSchemaIncludeTestFixture.cs new file mode 100644 index 0000000000..50e0fdac41 --- /dev/null +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Includes/AttributeGroupRefSchemaIncludeTestFixture.cs @@ -0,0 +1,48 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using ICSharpCode.TextEditor.Gui.CompletionWindow; +using ICSharpCode.XmlEditor; +using NUnit.Framework; +using System; +using System.IO; +using System.Text; +using System.Xml; +using XmlEditor.Tests.Utils; +using XmlEditor.Tests.Schema; + +namespace XmlEditor.Tests.Schema.Includes +{ + /// + /// Tests that schemas referenced via xs:include elements are used when + /// generating completion data. + /// + [TestFixture] + public class AttributeGroupRefSchemaIncludeTestFixture : AttributeGroupRefTestFixture + { + [TestFixtureTearDown] + public void FixtureTearDown() + { + SchemaIncludeTestFixtureHelper.FixtureTearDown(); + } + + protected override XmlSchemaCompletionData CreateSchemaCompletionDataObject() + { + return SchemaIncludeTestFixtureHelper.CreateSchemaCompletionDataObject(GetMainSchema(), GetSchema()); + } + + string GetMainSchema() + { + return "\r\n" + + "\t\r\n" + + ""; + } + } +} diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Includes/TwoElementSchemaIncludeTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Includes/TwoElementSchemaIncludeTestFixture.cs new file mode 100644 index 0000000000..0bbce39838 --- /dev/null +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Includes/TwoElementSchemaIncludeTestFixture.cs @@ -0,0 +1,48 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using ICSharpCode.TextEditor.Gui.CompletionWindow; +using ICSharpCode.XmlEditor; +using NUnit.Framework; +using System; +using System.IO; +using System.Text; +using System.Xml; +using XmlEditor.Tests.Utils; +using XmlEditor.Tests.Schema; + +namespace XmlEditor.Tests.Schema.Includes +{ + /// + /// Tests that schemas referenced via xs:include elements are used when + /// generating completion data. + /// + [TestFixture] + public class TwoElementSchemaIncludeTestFixture : TwoElementSchemaTestFixture + { + [TestFixtureTearDown] + public void FixtureTearDown() + { + SchemaIncludeTestFixtureHelper.FixtureTearDown(); + } + + protected override XmlSchemaCompletionData CreateSchemaCompletionDataObject() + { + return SchemaIncludeTestFixtureHelper.CreateSchemaCompletionDataObject(GetMainSchema(), GetSchema()); + } + + string GetMainSchema() + { + return "\r\n" + + "\t\r\n" + + ""; + } + } +} diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Uri/GetUriTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Uri/GetUriTestFixture.cs new file mode 100644 index 0000000000..4847d8df77 --- /dev/null +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Uri/GetUriTestFixture.cs @@ -0,0 +1,46 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using ICSharpCode.TextEditor.Gui.CompletionWindow; +using ICSharpCode.XmlEditor; +using NUnit.Framework; +using System; +using System.IO; +using System.Text; +using System.Xml; +using XmlEditor.Tests.Utils; + +namespace XmlEditor.Tests.Schema.Uri +{ + /// + /// Tests the method. + /// + [TestFixture] + public class GetUriTestFixture + { + [Test] + public void SimpleFileName() + { + string fileName = @"C:\temp\foo.xml"; + string expectedUri = "file:///C:/temp/foo.xml"; + + Assert.AreEqual(expectedUri, XmlSchemaCompletionData.GetUri(fileName)); + } + + [Test] + public void NullFileName() + { + Assert.AreEqual(String.Empty, XmlSchemaCompletionData.GetUri(null)); + } + + [Test] + public void EmptyString() + { + Assert.AreEqual(String.Empty, XmlSchemaCompletionData.GetUri(String.Empty)); + } + } +} diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AbstractElementTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AbstractElementTestFixture.cs new file mode 100644 index 0000000000..7b8e59e195 --- /dev/null +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AbstractElementTestFixture.cs @@ -0,0 +1,137 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision: 318 $ +// + +using ICSharpCode.TextEditor.Gui.CompletionWindow; +using ICSharpCode.XmlEditor; +using NUnit.Framework; +using System; +using System.IO; + +namespace XmlEditor.Tests.Schema +{ + /// + /// Tests elements that are abstract and require substitution groups. + /// + [TestFixture] + public class AbstractElementTestFixture : SchemaTestFixtureBase + { + ICompletionData[] itemsElementChildren; + ICompletionData[] fileElementAttributes; + ICompletionData[] fileElementChildren; + + public override void FixtureInit() + { + XmlElementPath path = new XmlElementPath(); + + path.Elements.Add(new QualifiedName("project", "http://foo")); + path.Elements.Add(new QualifiedName("items", "http://foo")); + + itemsElementChildren = SchemaCompletionData.GetChildElementCompletionData(path); + + path.Elements.Add(new QualifiedName("file", "http://foo")); + + fileElementAttributes = SchemaCompletionData.GetAttributeCompletionData(path); + fileElementChildren = SchemaCompletionData.GetChildElementCompletionData(path); + } + + [Test] + public void ItemsElementHasTwoChildElements() + { + Assert.AreEqual(2, itemsElementChildren.Length, + "Should be 2 child elements."); + } + + [Test] + public void ReferenceElementIsChildOfItemsElement() + { + Assert.IsTrue(SchemaTestFixtureBase.Contains(itemsElementChildren, "reference")); + } + + [Test] + public void FileElementIsChildOfItemsElement() + { + Assert.IsTrue(SchemaTestFixtureBase.Contains(itemsElementChildren, "file")); + } + + [Test] + public void FileElementHasAttributeNamedType() + { + Assert.IsTrue(SchemaTestFixtureBase.Contains(fileElementAttributes, "type")); + } + + [Test] + public void FileElementHasTwoChildElements() + { + Assert.AreEqual(2, fileElementChildren.Length, "Should be 2 child elements."); + } + + protected override string GetSchema() + { + return "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + "\r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + ""; + } + } +} diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeAnnotationTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeAnnotationTestFixture.cs index d2b2d02ce4..42b9b247da 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeAnnotationTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeAnnotationTestFixture.cs @@ -21,23 +21,18 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class AttributeAnnotationTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] fooAttributeCompletionData; ICompletionData[] barAttributeCompletionData; - [TestFixtureSetUp] - public void FixtureInit() - { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - + public override void FixtureInit() + { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("foo", "http://foo.com")); - fooAttributeCompletionData = schemaCompletionData.GetAttributeCompletionData(path); + fooAttributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path); path.Elements.Add(new QualifiedName("bar", "http://foo.com")); - barAttributeCompletionData = schemaCompletionData.GetAttributeCompletionData(path); + barAttributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path); } [Test] @@ -52,7 +47,7 @@ namespace XmlEditor.Tests.Schema Assert.AreEqual("Documentation for bar attribute.", barAttributeCompletionData[0].Description); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\t\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeGroupRefTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeGroupRefTestFixture.cs index a4f5765d25..f86a6393ee 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeGroupRefTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeGroupRefTestFixture.cs @@ -19,18 +19,13 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class AttributeGroupRefTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] attributeCompletionData; - [TestFixtureSetUp] - public void FixtureInit() - { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - + public override void FixtureInit() + { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); - attributeCompletionData = schemaCompletionData.GetAttributeCompletionData(path); + attributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path); } [Test] @@ -42,32 +37,32 @@ namespace XmlEditor.Tests.Schema [Test] public void NameAttribute() { - Assert.IsTrue(base.Contains(attributeCompletionData, "name"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeCompletionData, "name"), "Attribute name does not exist."); } [Test] public void IdAttribute() { - Assert.IsTrue(base.Contains(attributeCompletionData, "id"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeCompletionData, "id"), "Attribute id does not exist."); } [Test] public void StyleAttribute() { - Assert.IsTrue(base.Contains(attributeCompletionData, "style"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeCompletionData, "style"), "Attribute style does not exist."); } [Test] public void TitleAttribute() { - Assert.IsTrue(base.Contains(attributeCompletionData, "title"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeCompletionData, "title"), "Attribute title does not exist."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeRefTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeRefTestFixture.cs index c1c8f96024..18207744fe 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeRefTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeRefTestFixture.cs @@ -19,17 +19,13 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class AttributeRefTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] attributes; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("html", "http://foo/xhtml")); - attributes = schemaCompletionData.GetAttributeCompletionData(path); + attributes = SchemaCompletionData.GetAttributeCompletionData(path); } [Test] @@ -42,28 +38,28 @@ namespace XmlEditor.Tests.Schema [Test] public void HtmlLangAttribute() { - Assert.IsTrue(base.Contains(attributes, "lang"), "Attribute lang not found."); + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "lang"), "Attribute lang not found."); } [Test] public void HtmlIdAttribute() { - Assert.IsTrue(base.Contains(attributes, "id"), "Attribute id not found."); + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "id"), "Attribute id not found."); } [Test] public void HtmlDirAttribute() { - Assert.IsTrue(base.Contains(attributes, "dir"), "Attribute dir not found."); + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "dir"), "Attribute dir not found."); } [Test] public void HtmlXmlLangAttribute() { - Assert.IsTrue(base.Contains(attributes, "xml:lang"), "Attribute xml:lang not found."); + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "xml:lang"), "Attribute xml:lang not found."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + " \r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChoiceTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChoiceTestFixture.cs index cd8d059191..e8f4a12179 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChoiceTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChoiceTestFixture.cs @@ -20,19 +20,14 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class ChoiceTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] noteChildElements; - [TestFixtureSetUp] - public void FixtureInit() - { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - + public override void FixtureInit() + { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); - noteChildElements = schemaCompletionData.GetChildElementCompletionData(path); + noteChildElements = SchemaCompletionData.GetChildElementCompletionData(path); } [Test] @@ -41,7 +36,7 @@ namespace XmlEditor.Tests.Schema XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); path.Elements.Add(new QualifiedName("title", "http://www.w3schools.com")); - Assert.AreEqual(0, schemaCompletionData.GetChildElementCompletionData(path).Length, + Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length, "Should be no child elements."); } @@ -51,7 +46,7 @@ namespace XmlEditor.Tests.Schema XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); path.Elements.Add(new QualifiedName("text", "http://www.w3schools.com")); - Assert.AreEqual(0, schemaCompletionData.GetChildElementCompletionData(path).Length, + Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length, "Should be no child elements."); } @@ -65,18 +60,18 @@ namespace XmlEditor.Tests.Schema [Test] public void NoteChildElementIsText() { - Assert.IsTrue(base.Contains(noteChildElements, "text"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "text"), "Should have a child element called text."); } [Test] public void NoteChildElementIsTitle() { - Assert.IsTrue(base.Contains(noteChildElements, "title"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "title"), "Should have a child element called title."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\t\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ComplexContentExtensionTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ComplexContentExtensionTestFixture.cs index ba9e300ef1..0eb6f0ae6c 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ComplexContentExtensionTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ComplexContentExtensionTestFixture.cs @@ -19,21 +19,16 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class ComplexContentExtensionTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] bodyChildElements; ICompletionData[] bodyAttributes; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("body", "http://www.w3schools.com")); - bodyChildElements = schemaCompletionData.GetChildElementCompletionData(path); - bodyAttributes = schemaCompletionData.GetAttributeCompletionData(path); + bodyChildElements = SchemaCompletionData.GetChildElementCompletionData(path); + bodyAttributes = SchemaCompletionData.GetAttributeCompletionData(path); } [Test] @@ -43,7 +38,7 @@ namespace XmlEditor.Tests.Schema path.Elements.Add(new QualifiedName("body", "http://www.w3schools.com")); path.Elements.Add(new QualifiedName("title", "http://www.w3schools.com")); - Assert.AreEqual(0, schemaCompletionData.GetChildElementCompletionData(path).Length, + Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length, "Should be no child elements."); } @@ -54,7 +49,7 @@ namespace XmlEditor.Tests.Schema path.Elements.Add(new QualifiedName("body", "http://www.w3schools.com")); path.Elements.Add(new QualifiedName("text", "http://www.w3schools.com")); - Assert.AreEqual(0, schemaCompletionData.GetChildElementCompletionData(path).Length, + Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length, "Should be no child elements."); } @@ -68,14 +63,14 @@ namespace XmlEditor.Tests.Schema [Test] public void BodyChildElementIsText() { - Assert.IsTrue(base.Contains(bodyChildElements, "text"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(bodyChildElements, "text"), "Should have a child element called text."); } [Test] public void BodyChildElementIsTitle() { - Assert.IsTrue(base.Contains(bodyChildElements, "title"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(bodyChildElements, "title"), "Should have a child element called title."); } @@ -89,10 +84,10 @@ namespace XmlEditor.Tests.Schema [Test] public void BodyAttributeName() { - Assert.IsTrue(base.Contains(bodyAttributes, "id"), "Attribute id not found."); + Assert.IsTrue(SchemaTestFixtureBase.Contains(bodyAttributes, "id"), "Attribute id not found."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\t\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/DuplicateElementTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/DuplicateElementTestFixture.cs index 77f7ed340f..9dc8a1065d 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/DuplicateElementTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/DuplicateElementTestFixture.cs @@ -19,19 +19,14 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class DuplicateElementTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] htmlChildElements; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("html", "http://foo/xhtml")); - htmlChildElements = schemaCompletionData.GetChildElementCompletionData(path); + htmlChildElements = SchemaCompletionData.GetChildElementCompletionData(path); } [Test] @@ -44,18 +39,18 @@ namespace XmlEditor.Tests.Schema [Test] public void HtmlChildElementHead() { - Assert.IsTrue(base.Contains(htmlChildElements, "head"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(htmlChildElements, "head"), "Should have a child element called head."); } [Test] public void HtmlChildElementBody() { - Assert.IsTrue(base.Contains(htmlChildElements, "body"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(htmlChildElements, "body"), "Should have a child element called body."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\t\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementRefAnnotationTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementRefAnnotationTestFixture.cs index 9300b834a8..7bbd7dc0a1 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementRefAnnotationTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementRefAnnotationTestFixture.cs @@ -21,29 +21,24 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class ElementRefAnnotationTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] fooChildElementCompletionData; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("foo", "http://foo.com")); - fooChildElementCompletionData = schemaCompletionData.GetChildElementCompletionData(path); + fooChildElementCompletionData = SchemaCompletionData.GetChildElementCompletionData(path); } [Test] public void BarElementDocumentation() { - Assert.IsTrue(base.ContainsDescription(fooChildElementCompletionData, "bar", "Documentation for bar element."), + Assert.IsTrue(SchemaTestFixtureBase.ContainsDescription(fooChildElementCompletionData, "bar", "Documentation for bar element."), "Missing documentation for bar element"); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\t\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementWithAttributeSchemaTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementWithAttributeSchemaTestFixture.cs index bedd5c3616..6afa9c4561 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementWithAttributeSchemaTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementWithAttributeSchemaTestFixture.cs @@ -17,22 +17,17 @@ namespace XmlEditor.Tests.Schema /// Element that has a single attribute. /// [TestFixture] - public class ElementWithAttributeSchemaTestFixture + public class ElementWithAttributeSchemaTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] attributeCompletionData; string attributeName; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); - attributeCompletionData = schemaCompletionData.GetAttributeCompletionData(path); + attributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path); attributeName = attributeCompletionData[0].Text; } @@ -53,12 +48,12 @@ namespace XmlEditor.Tests.Schema { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("foobar", "http://www.w3schools.com")); - ICompletionData[] attributes = schemaCompletionData.GetAttributeCompletionData(path); + ICompletionData[] attributes = SchemaCompletionData.GetAttributeCompletionData(path); Assert.AreEqual(0, attributes.Length, "Should not find attributes for unknown element."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + " \r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/EnumAttributeValueTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/EnumAttributeValueTestFixture.cs index ce10daf726..4be63f8f5e 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/EnumAttributeValueTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/EnumAttributeValueTestFixture.cs @@ -19,30 +19,26 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class EnumAttributeValueTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] attributeValues; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("foo", "http://foo.com")); - attributeValues = schemaCompletionData.GetAttributeValueCompletionData(path, "id"); + attributeValues = SchemaCompletionData.GetAttributeValueCompletionData(path, "id"); } [Test] public void IdAttributeHasValueOne() { - Assert.IsTrue(base.Contains(attributeValues, "one"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeValues, "one"), "Missing attribute value 'one'"); } [Test] public void IdAttributeHasValueTwo() { - Assert.IsTrue(base.Contains(attributeValues, "two"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeValues, "two"), "Missing attribute value 'two'"); } @@ -52,7 +48,7 @@ namespace XmlEditor.Tests.Schema Assert.AreEqual(2, attributeValues.Length, "Expecting 2 attribute values."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\t\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ExtensionElementTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ExtensionElementTestFixture.cs index 9c2d8b58a2..d35c886fdf 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ExtensionElementTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ExtensionElementTestFixture.cs @@ -19,7 +19,6 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class ExtensionElementTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] schemaChildElements; ICompletionData[] annotationChildElements; ICompletionData[] annotationAttributes; @@ -28,36 +27,33 @@ namespace XmlEditor.Tests.Schema ICompletionData[] schemaAttributes; ICompletionData[] fooAttributes; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("schema", "http://www.w3.org/2001/XMLSchema")); - schemaChildElements = schemaCompletionData.GetChildElementCompletionData(path); - schemaAttributes = schemaCompletionData.GetAttributeCompletionData(path); + schemaChildElements = SchemaCompletionData.GetChildElementCompletionData(path); + schemaAttributes = SchemaCompletionData.GetAttributeCompletionData(path); // Get include elements attributes. path.Elements.Add(new QualifiedName("include", "http://www.w3.org/2001/XMLSchema")); - includeAttributes = schemaCompletionData.GetAttributeCompletionData(path); + includeAttributes = SchemaCompletionData.GetAttributeCompletionData(path); // Get annotation element info. path.Elements.RemoveLast(); path.Elements.Add(new QualifiedName("annotation", "http://www.w3.org/2001/XMLSchema")); - annotationChildElements = schemaCompletionData.GetChildElementCompletionData(path); - annotationAttributes = schemaCompletionData.GetAttributeCompletionData(path); + annotationChildElements = SchemaCompletionData.GetChildElementCompletionData(path); + annotationAttributes = SchemaCompletionData.GetAttributeCompletionData(path); // Get app info attributes. path.Elements.Add(new QualifiedName("appinfo", "http://www.w3.org/2001/XMLSchema")); - appInfoAttributes = schemaCompletionData.GetAttributeCompletionData(path); + appInfoAttributes = SchemaCompletionData.GetAttributeCompletionData(path); // Get foo attributes. path = new XmlElementPath(); path.Elements.Add(new QualifiedName("foo", "http://www.w3.org/2001/XMLSchema")); - fooAttributes = schemaCompletionData.GetAttributeCompletionData(path); + fooAttributes = SchemaCompletionData.GetAttributeCompletionData(path); } [Test] @@ -70,21 +66,21 @@ namespace XmlEditor.Tests.Schema [Test] public void SchemaChildElementIsInclude() { - Assert.IsTrue(base.Contains(schemaChildElements, "include"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(schemaChildElements, "include"), "Should have a child element called include."); } [Test] public void SchemaChildElementIsImport() { - Assert.IsTrue(base.Contains(schemaChildElements, "import"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(schemaChildElements, "import"), "Should have a child element called import."); } [Test] public void SchemaChildElementIsNotation() { - Assert.IsTrue(base.Contains(schemaChildElements, "notation"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(schemaChildElements, "notation"), "Should have a child element called notation."); } @@ -94,7 +90,7 @@ namespace XmlEditor.Tests.Schema [Test] public void FooHasClassAttribute() { - Assert.IsTrue(base.Contains(fooAttributes, "class"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(fooAttributes, "class"), "Should have an attribute called class."); } @@ -107,7 +103,7 @@ namespace XmlEditor.Tests.Schema [Test] public void AnnotationHasIdAttribute() { - Assert.IsTrue(base.Contains(annotationAttributes, "id"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(annotationAttributes, "id"), "Should have an attribute called id."); } @@ -121,14 +117,14 @@ namespace XmlEditor.Tests.Schema [Test] public void AnnotationChildElementIsAppInfo() { - Assert.IsTrue(base.Contains(annotationChildElements, "appinfo"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(annotationChildElements, "appinfo"), "Should have a child element called appinfo."); } [Test] public void AnnotationChildElementIsDocumentation() { - Assert.IsTrue(base.Contains(annotationChildElements, "documentation"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(annotationChildElements, "documentation"), "Should have a child element called documentation."); } @@ -141,7 +137,7 @@ namespace XmlEditor.Tests.Schema [Test] public void IncludeHasSchemaLocationAttribute() { - Assert.IsTrue(base.Contains(includeAttributes, "schemaLocation"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(includeAttributes, "schemaLocation"), "Should have an attribute called schemaLocation."); } @@ -154,11 +150,11 @@ namespace XmlEditor.Tests.Schema [Test] public void AppInfoHasIdAttribute() { - Assert.IsTrue(base.Contains(appInfoAttributes, "id"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(appInfoAttributes, "id"), "Should have an attribute called id."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefCompositorTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefCompositorTestFixture.cs index 48a9d81223..c9a6eaeb5b 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefCompositorTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefCompositorTestFixture.cs @@ -23,24 +23,19 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class GroupRefAsCompositorTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] rootChildElements; ICompletionData[] fooAttributes; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("root", "http://foo")); - rootChildElements = schemaCompletionData.GetChildElementCompletionData(path); + rootChildElements = SchemaCompletionData.GetChildElementCompletionData(path); path.Elements.Add(new QualifiedName("foo", "http://foo")); - fooAttributes = schemaCompletionData.GetAttributeCompletionData(path); + fooAttributes = SchemaCompletionData.GetAttributeCompletionData(path); } [Test] @@ -53,25 +48,25 @@ namespace XmlEditor.Tests.Schema [Test] public void RootChildElementIsFoo() { - Assert.IsTrue(base.Contains(rootChildElements, "foo"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(rootChildElements, "foo"), "Should have a child element called foo."); } [Test] public void RootChildElementIsBar() { - Assert.IsTrue(base.Contains(rootChildElements, "bar"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(rootChildElements, "bar"), "Should have a child element called bar."); } [Test] public void FooElementHasIdAttribute() { - Assert.IsTrue(base.Contains(fooAttributes, "id"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(fooAttributes, "id"), "Should have an attribute called id."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\t\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefTestFixture.cs index fb367a08df..c4bef2e7ef 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefTestFixture.cs @@ -19,24 +19,20 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class GroupRefTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] childElements; ICompletionData[] paraAttributes; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("html", "http://foo/xhtml")); path.Elements.Add(new QualifiedName("body", "http://foo/xhtml")); - childElements = schemaCompletionData.GetChildElementCompletionData(path); + childElements = SchemaCompletionData.GetChildElementCompletionData(path); path.Elements.Add(new QualifiedName("p", "http://foo/xhtml")); - paraAttributes = schemaCompletionData.GetAttributeCompletionData(path); + paraAttributes = SchemaCompletionData.GetAttributeCompletionData(path); } [Test] @@ -49,39 +45,39 @@ namespace XmlEditor.Tests.Schema [Test] public void BodyChildElementForm() { - Assert.IsTrue(base.Contains(childElements, "form"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "form"), "Should have a child element called form."); } [Test] public void BodyChildElementPara() { - Assert.IsTrue(base.Contains(childElements, "p"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "p"), "Should have a child element called p."); } [Test] public void BodyChildElementTest() { - Assert.IsTrue(base.Contains(childElements, "test"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "test"), "Should have a child element called test."); } [Test] public void BodyChildElementId() { - Assert.IsTrue(base.Contains(childElements, "id"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "id"), "Should have a child element called id."); } [Test] public void ParaElementHasIdAttribute() { - Assert.IsTrue(base.Contains(paraAttributes, "id"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(paraAttributes, "id"), "Should have an attribute called id."); } - string GetSchema() + protected override string GetSchema() { return " [TestFixture] - public class NamespaceCompletionTestFixture : SchemaTestFixtureBase + public class NamespaceCompletionTestFixture { ICompletionData[] namespaceCompletionData; string firstNamespace = "http://foo.com/foo.xsd"; @@ -49,13 +49,13 @@ namespace XmlEditor.Tests.Schema [Test] public void ContainsFirstNamespace() { - Assert.IsTrue(Contains(namespaceCompletionData, firstNamespace)); + Assert.IsTrue(SchemaTestFixtureBase.Contains(namespaceCompletionData, firstNamespace)); } [Test] public void ContainsSecondNamespace() { - Assert.IsTrue(Contains(namespaceCompletionData, secondNamespace)); + Assert.IsTrue(SchemaTestFixtureBase.Contains(namespaceCompletionData, secondNamespace)); } string GetSchema(string namespaceURI) diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedAttributeGroupRefTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedAttributeGroupRefTestFixture.cs index 6d97c1348c..f7c1ded066 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedAttributeGroupRefTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedAttributeGroupRefTestFixture.cs @@ -19,18 +19,13 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class NestedAttributeGroupRefTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] attributeCompletionData; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); - attributeCompletionData = schemaCompletionData.GetAttributeCompletionData(path); + attributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path); } [Test] @@ -42,53 +37,53 @@ namespace XmlEditor.Tests.Schema [Test] public void NameAttribute() { - Assert.IsTrue(base.Contains(attributeCompletionData, "name"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeCompletionData, "name"), "Attribute name does not exist."); } [Test] public void IdAttribute() { - Assert.IsTrue(base.Contains(attributeCompletionData, "id"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeCompletionData, "id"), "Attribute id does not exist."); } [Test] public void StyleAttribute() { - Assert.IsTrue(base.Contains(attributeCompletionData, "style"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeCompletionData, "style"), "Attribute style does not exist."); } [Test] public void TitleAttribute() { - Assert.IsTrue(base.Contains(attributeCompletionData, "title"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeCompletionData, "title"), "Attribute title does not exist."); } [Test] public void BaseIdAttribute() { - Assert.IsTrue(base.Contains(attributeCompletionData, "baseid"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeCompletionData, "baseid"), "Attribute baseid does not exist."); } [Test] public void BaseStyleAttribute() { - Assert.IsTrue(base.Contains(attributeCompletionData, "basestyle"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeCompletionData, "basestyle"), "Attribute basestyle does not exist."); } [Test] public void BaseTitleAttribute() { - Assert.IsTrue(base.Contains(attributeCompletionData, "basetitle"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeCompletionData, "basetitle"), "Attribute basetitle does not exist."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedChoiceTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedChoiceTestFixture.cs index 8257303c3c..feb507c74c 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedChoiceTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedChoiceTestFixture.cs @@ -20,25 +20,20 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class NestedChoiceTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] noteChildElements; ICompletionData[] titleChildElements; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - // Get note child elements. XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); - noteChildElements = schemaCompletionData.GetChildElementCompletionData(path); + noteChildElements = SchemaCompletionData.GetChildElementCompletionData(path); // Get title child elements. path.Elements.Add(new QualifiedName("title", "http://www.w3schools.com")); - titleChildElements = schemaCompletionData.GetChildElementCompletionData(path); + titleChildElements = SchemaCompletionData.GetChildElementCompletionData(path); } [Test] @@ -54,7 +49,7 @@ namespace XmlEditor.Tests.Schema XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); path.Elements.Add(new QualifiedName("text", "http://www.w3schools.com")); - Assert.AreEqual(0, schemaCompletionData.GetChildElementCompletionData(path).Length, + Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length, "Should be no child elements."); } @@ -68,18 +63,18 @@ namespace XmlEditor.Tests.Schema [Test] public void NoteChildElementIsText() { - Assert.IsTrue(base.Contains(noteChildElements, "text"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "text"), "Should have a child element called text."); } [Test] public void NoteChildElementIsTitle() { - Assert.IsTrue(base.Contains(noteChildElements, "title"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "title"), "Should have a child element called title."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\t\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedElementSchemaTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedElementSchemaTestFixture.cs index ca88948168..3aed674068 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedElementSchemaTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedElementSchemaTestFixture.cs @@ -16,20 +16,15 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class NestedElementSchemaTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; XmlElementPath noteElementPath; ICompletionData[] elementData; - [TestFixtureSetUp] - public void FixtureInit() - { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - + public override void FixtureInit() + { noteElementPath = new XmlElementPath(); noteElementPath.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); - elementData = schemaCompletionData.GetChildElementCompletionData(noteElementPath); + elementData = SchemaCompletionData.GetChildElementCompletionData(noteElementPath); } [Test] @@ -41,11 +36,11 @@ namespace XmlEditor.Tests.Schema [Test] public void NoteChildElementCompletionDataText() { - Assert.IsTrue(base.Contains(elementData, "text"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(elementData, "text"), "Should be one child element called text."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\t\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedSequenceTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedSequenceTestFixture.cs index a7f6222569..7ce658bdad 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedSequenceTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedSequenceTestFixture.cs @@ -20,18 +20,13 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class NestedSequenceSchemaTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] noteChildElements; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); - noteChildElements = schemaCompletionData.GetChildElementCompletionData(path); + noteChildElements = SchemaCompletionData.GetChildElementCompletionData(path); } [Test] @@ -40,7 +35,7 @@ namespace XmlEditor.Tests.Schema XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); path.Elements.Add(new QualifiedName("title", "http://www.w3schools.com")); - Assert.AreEqual(0, schemaCompletionData.GetChildElementCompletionData(path).Length, + Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length, "Should be no child elements."); } @@ -50,7 +45,7 @@ namespace XmlEditor.Tests.Schema XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); path.Elements.Add(new QualifiedName("text", "http://www.w3schools.com")); - Assert.AreEqual(0, schemaCompletionData.GetChildElementCompletionData(path).Length, + Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length, "Should be no child elements."); } @@ -64,18 +59,18 @@ namespace XmlEditor.Tests.Schema [Test] public void NoteChildElementIsText() { - Assert.IsTrue(base.Contains(noteChildElements, "text"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "text"), "Should have a child element called text."); } [Test] public void NoteChildElementIsTitle() { - Assert.IsTrue(base.Contains(noteChildElements, "title"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "title"), "Should have a child element called title."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\t\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ReferencedElementsTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ReferencedElementsTestFixture.cs index 1336db6597..1f44758dc8 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ReferencedElementsTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ReferencedElementsTestFixture.cs @@ -16,31 +16,26 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class ReferencedElementsTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] shipOrderAttributes; ICompletionData[] shipToAttributes; XmlElementPath shipToPath; XmlElementPath shipOrderPath; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - // Get shipto attributes. shipToPath = new XmlElementPath(); QualifiedName shipOrderName = new QualifiedName("shiporder", "http://www.w3schools.com"); shipToPath.Elements.Add(shipOrderName); shipToPath.Elements.Add(new QualifiedName("shipto", "http://www.w3schools.com")); - shipToAttributes = schemaCompletionData.GetAttributeCompletionData(shipToPath); + shipToAttributes = SchemaCompletionData.GetAttributeCompletionData(shipToPath); // Get shiporder attributes. shipOrderPath = new XmlElementPath(); shipOrderPath.Elements.Add(shipOrderName); - shipOrderAttributes = schemaCompletionData.GetAttributeCompletionData(shipOrderPath); + shipOrderAttributes = SchemaCompletionData.GetAttributeCompletionData(shipOrderPath); } @@ -53,7 +48,7 @@ namespace XmlEditor.Tests.Schema [Test] public void ShipOrderAttributeName() { - Assert.IsTrue(base.Contains(shipOrderAttributes,"id"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(shipOrderAttributes,"id"), "Incorrect shiporder attribute name."); } @@ -66,49 +61,49 @@ namespace XmlEditor.Tests.Schema [Test] public void ShipToAttributeName() { - Assert.IsTrue(base.Contains(shipToAttributes, "address"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(shipToAttributes, "address"), "Incorrect shipto attribute name."); } [Test] public void ShipOrderChildElementsCount() { - Assert.AreEqual(1, schemaCompletionData.GetChildElementCompletionData(shipOrderPath).Length, + Assert.AreEqual(1, SchemaCompletionData.GetChildElementCompletionData(shipOrderPath).Length, "Should be one child element."); } [Test] public void ShipOrderHasShipToChildElement() { - ICompletionData[] data = schemaCompletionData.GetChildElementCompletionData(shipOrderPath); - Assert.IsTrue(base.Contains(data, "shipto"), + ICompletionData[] data = SchemaCompletionData.GetChildElementCompletionData(shipOrderPath); + Assert.IsTrue(SchemaTestFixtureBase.Contains(data, "shipto"), "Incorrect child element name."); } [Test] public void ShipToChildElementsCount() { - Assert.AreEqual(2, schemaCompletionData.GetChildElementCompletionData(shipToPath).Length, + Assert.AreEqual(2, SchemaCompletionData.GetChildElementCompletionData(shipToPath).Length, "Should be 2 child elements."); } [Test] public void ShipToHasNameChildElement() { - ICompletionData[] data = schemaCompletionData.GetChildElementCompletionData(shipToPath); - Assert.IsTrue(base.Contains(data, "name"), + ICompletionData[] data = SchemaCompletionData.GetChildElementCompletionData(shipToPath); + Assert.IsTrue(SchemaTestFixtureBase.Contains(data, "name"), "Incorrect child element name."); } [Test] public void ShipToHasAddressChildElement() { - ICompletionData[] data = schemaCompletionData.GetChildElementCompletionData(shipToPath); - Assert.IsTrue(base.Contains(data, "address"), + ICompletionData[] data = SchemaCompletionData.GetChildElementCompletionData(shipToPath); + Assert.IsTrue(SchemaTestFixtureBase.Contains(data, "address"), "Incorrect child element name."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/RestrictionElementTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/RestrictionElementTestFixture.cs index 3533efa315..4996a55e13 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/RestrictionElementTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/RestrictionElementTestFixture.cs @@ -19,83 +19,78 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class RestrictionElementTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] childElements; ICompletionData[] attributes; ICompletionData[] annotationChildElements; ICompletionData[] choiceChildElements; - [TestFixtureSetUp] - public void FixtureInit() - { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - + public override void FixtureInit() + { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("group", "http://www.w3.org/2001/XMLSchema")); - childElements = schemaCompletionData.GetChildElementCompletionData(path); - attributes = schemaCompletionData.GetAttributeCompletionData(path); + childElements = SchemaCompletionData.GetChildElementCompletionData(path); + attributes = SchemaCompletionData.GetAttributeCompletionData(path); // Get annotation child elements. path.Elements.Add(new QualifiedName("annotation", "http://www.w3.org/2001/XMLSchema")); - annotationChildElements = schemaCompletionData.GetChildElementCompletionData(path); + annotationChildElements = SchemaCompletionData.GetChildElementCompletionData(path); // Get choice child elements. path.Elements.RemoveLast(); path.Elements.Add(new QualifiedName("choice", "http://www.w3.org/2001/XMLSchema")); - choiceChildElements = schemaCompletionData.GetChildElementCompletionData(path); + choiceChildElements = SchemaCompletionData.GetChildElementCompletionData(path); } [Test] public void GroupChildElementIsAnnotation() { - Assert.IsTrue(base.Contains(childElements, "annotation"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "annotation"), "Should have a child element called annotation."); } [Test] public void GroupChildElementIsChoice() { - Assert.IsTrue(base.Contains(childElements, "choice"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "choice"), "Should have a child element called choice."); } [Test] public void GroupChildElementIsSequence() { - Assert.IsTrue(base.Contains(childElements, "sequence"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(childElements, "sequence"), "Should have a child element called sequence."); } [Test] public void GroupAttributeIsName() { - Assert.IsTrue(base.Contains(attributes, "name"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "name"), "Should have an attribute called name."); } [Test] public void AnnotationChildElementIsAppInfo() { - Assert.IsTrue(base.Contains(annotationChildElements, "appinfo"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(annotationChildElements, "appinfo"), "Should have a child element called appinfo."); } [Test] public void AnnotationChildElementIsDocumentation() { - Assert.IsTrue(base.Contains(annotationChildElements, "documentation"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(annotationChildElements, "documentation"), "Should have a child element called appinfo."); } [Test] public void ChoiceChildElementIsSequence() { - Assert.IsTrue(base.Contains(choiceChildElements, "element"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(choiceChildElements, "element"), "Should have a child element called element."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs index fc5fe54205..4bfee76a52 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs @@ -6,17 +6,112 @@ // using ICSharpCode.TextEditor.Gui.CompletionWindow; +using ICSharpCode.XmlEditor; using NUnit.Framework; using System; +using System.IO; namespace XmlEditor.Tests.Schema { +// public abstract class SchemaTestFixtureBase +// { +// /// +// /// Checks whether the specified name exists in the completion data. +// /// +// protected bool Contains(ICompletionData[] items, string name) +// { +// bool Contains = false; +// +// foreach (ICompletionData data in items) { +// if (data.Text[0] == name) { +// Contains = true; +// break; +// } +// } +// +// return Contains; +// } +// +// /// +// /// Checks whether the completion data specified by name has +// /// the correct description. +// /// +// protected bool ContainsDescription(ICompletionData[] items, string name, string description) +// { +// bool Contains = false; +// +// foreach (ICompletionData data in items) { +// if (data.Text[0] == name) { +// if (data.Description == description) { +// Contains = true; +// break; +// } +// } +// } +// +// return Contains; +// } +// +// /// +// /// Gets a count of the number of occurrences of a particular name +// /// in the completion data. +// /// +// protected int GetItemCount(ICompletionData[] items, string name) +// { +// int count = 0; +// +// foreach (ICompletionData data in items) { +// if (data.Text[0] == name) { +// ++count; +// } +// } +// +// return count; +// } +// } + + [TestFixture] public abstract class SchemaTestFixtureBase - { + { + XmlSchemaCompletionData schemaCompletionData; + + /// + /// Gets the object generated + /// by this class. + /// + /// This object will be null until the + /// has been run. + public XmlSchemaCompletionData SchemaCompletionData { + get { + return schemaCompletionData; + } + } + + /// + /// Creates the object from + /// the derived class's schema. + /// + /// Calls at the end of the method. + /// + [TestFixtureSetUp] + public void FixtureInitBase() + { + schemaCompletionData = CreateSchemaCompletionDataObject(); + FixtureInit(); + } + + /// + /// Method overridden by derived class so it can execute its own + /// fixture initialisation. + /// + public virtual void FixtureInit() + { + } + /// /// Checks whether the specified name exists in the completion data. /// - protected bool Contains(ICompletionData[] items, string name) + public static bool Contains(ICompletionData[] items, string name) { bool Contains = false; @@ -34,7 +129,7 @@ namespace XmlEditor.Tests.Schema /// Checks whether the completion data specified by name has /// the correct description. /// - protected bool ContainsDescription(ICompletionData[] items, string name, string description) + public static bool ContainsDescription(ICompletionData[] items, string name, string description) { bool Contains = false; @@ -54,7 +149,7 @@ namespace XmlEditor.Tests.Schema /// Gets a count of the number of occurrences of a particular name /// in the completion data. /// - protected int GetItemCount(ICompletionData[] items, string name) + public static int GetItemCount(ICompletionData[] items, string name) { int count = 0; @@ -66,5 +161,24 @@ namespace XmlEditor.Tests.Schema return count; } + + /// + /// Returns the schema that will be used in this test fixture. + /// + /// + protected virtual string GetSchema() + { + return String.Empty; + } + + /// + /// Creates an object that + /// will be used in the test fixture. + /// + protected virtual XmlSchemaCompletionData CreateSchemaCompletionDataObject() + { + StringReader reader = new StringReader(GetSchema()); + return new XmlSchemaCompletionData(reader); + } } } diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SequencedChoiceTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SequencedChoiceTestFixture.cs index bc2f64b82a..d81ca5099a 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SequencedChoiceTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SequencedChoiceTestFixture.cs @@ -20,19 +20,14 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class SequencedChoiceTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] noteChildElements; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); - noteChildElements = schemaCompletionData.GetChildElementCompletionData(path); + noteChildElements = SchemaCompletionData.GetChildElementCompletionData(path); } [Test] @@ -42,7 +37,7 @@ namespace XmlEditor.Tests.Schema path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); path.Elements.Add(new QualifiedName("title", "http://www.w3schools.com")); - Assert.AreEqual(0, schemaCompletionData.GetChildElementCompletionData(path).Length, + Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length, "Should be no child elements."); } @@ -53,7 +48,7 @@ namespace XmlEditor.Tests.Schema path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com")); path.Elements.Add(new QualifiedName("title", "http://www.w3schools.com")); - Assert.AreEqual(0, schemaCompletionData.GetChildElementCompletionData(path).Length, + Assert.AreEqual(0, SchemaCompletionData.GetChildElementCompletionData(path).Length, "Should be no child elements."); } @@ -67,18 +62,18 @@ namespace XmlEditor.Tests.Schema [Test] public void NoteChildElementIsText() { - Assert.IsTrue(base.Contains(noteChildElements, "text"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "text"), "Should have a child element called text."); } [Test] public void NoteChildElementIsTitle() { - Assert.IsTrue(base.Contains(noteChildElements, "title"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "title"), "Should have a child element called title."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\t\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SimpleContentWithAttributeTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SimpleContentWithAttributeTestFixture.cs index a9a80328a8..be39da2891 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SimpleContentWithAttributeTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SimpleContentWithAttributeTestFixture.cs @@ -19,29 +19,24 @@ namespace XmlEditor.Tests.Schema [TestFixture] public class SimpleContentWithAttributeSchemaTestFixture : SchemaTestFixtureBase { - XmlSchemaCompletionData schemaCompletionData; ICompletionData[] attributeCompletionData; - [TestFixtureSetUp] - public void FixtureInit() + public override void FixtureInit() { - StringReader reader = new StringReader(GetSchema()); - schemaCompletionData = new XmlSchemaCompletionData(reader); - XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("foo", "http://foo.com")); - attributeCompletionData = schemaCompletionData.GetAttributeCompletionData(path); + attributeCompletionData = SchemaCompletionData.GetAttributeCompletionData(path); } [Test] public void BarAttributeExists() { - Assert.IsTrue(base.Contains(attributeCompletionData, "bar"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(attributeCompletionData, "bar"), "Attribute bar does not exist."); } - string GetSchema() + protected override string GetSchema() { return "\r\n" + "\r\n" + "\t\r\n" + diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XsdSchemaTestFixture.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XsdSchemaTestFixture.cs index 89caebcbaf..b9fa97bb82 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XsdSchemaTestFixture.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XsdSchemaTestFixture.cs @@ -19,7 +19,7 @@ namespace XmlEditor.Tests.Schema /// Tests the xsd schema. /// [TestFixture] - public class XsdSchemaTestFixture : SchemaTestFixtureBase + public class XsdSchemaTestFixture { XmlSchemaCompletionData schemaCompletionData; XmlElementPath choicePath; @@ -101,14 +101,14 @@ namespace XmlEditor.Tests.Schema [Test] public void ChoiceHasMinOccursAttribute() { - Assert.IsTrue(base.Contains(choiceAttributes, "minOccurs"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(choiceAttributes, "minOccurs"), "Attribute minOccurs missing."); } [Test] public void ChoiceHasMaxOccursAttribute() { - Assert.IsTrue(base.Contains(choiceAttributes, "maxOccurs"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(choiceAttributes, "maxOccurs"), "Attribute maxOccurs missing."); } @@ -118,7 +118,7 @@ namespace XmlEditor.Tests.Schema [Test] public void ChoiceDoesNotHaveNameAttribute() { - Assert.IsFalse(base.Contains(choiceAttributes, "name"), + Assert.IsFalse(SchemaTestFixtureBase.Contains(choiceAttributes, "name"), "Attribute name should not exist."); } @@ -128,7 +128,7 @@ namespace XmlEditor.Tests.Schema [Test] public void ChoiceDoesNotHaveRefAttribute() { - Assert.IsFalse(base.Contains(choiceAttributes, "ref"), + Assert.IsFalse(SchemaTestFixtureBase.Contains(choiceAttributes, "ref"), "Attribute ref should not exist."); } @@ -138,56 +138,56 @@ namespace XmlEditor.Tests.Schema [Test] public void ElementNameAttributeAppearsOnce() { - int nameAttributeCount = base.GetItemCount(elementAttributes, "name"); + int nameAttributeCount = SchemaTestFixtureBase.GetItemCount(elementAttributes, "name"); Assert.AreEqual(1, nameAttributeCount, "Should be only one name attribute."); } [Test] public void ElementHasIdAttribute() { - Assert.IsTrue(base.Contains(elementAttributes, "id"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(elementAttributes, "id"), "id attribute missing."); } [Test] public void SimpleRestrictionTypeHasEnumChildElement() { - Assert.IsTrue(base.Contains(simpleEnumElements, "xs:enumeration"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(simpleEnumElements, "xs:enumeration"), "enumeration element missing."); } [Test] public void EnumHasValueAttribute() { - Assert.IsTrue(base.Contains(enumAttributes, "value"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(enumAttributes, "value"), "Attribute value missing."); } [Test] public void ElementFormDefaultAttributeHasValueQualified() { - Assert.IsTrue(base.Contains(elementFormDefaultAttributeValues, "qualified"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(elementFormDefaultAttributeValues, "qualified"), "Attribute value 'qualified' missing."); } [Test] public void BlockDefaultAttributeHasValueAll() { - Assert.IsTrue(base.Contains(blockDefaultAttributeValues, "#all"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(blockDefaultAttributeValues, "#all"), "Attribute value '#all' missing."); } [Test] public void BlockDefaultAttributeHasValueExtension() { - Assert.IsTrue(base.Contains(blockDefaultAttributeValues, "extension"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(blockDefaultAttributeValues, "extension"), "Attribute value 'extension' missing."); } [Test] public void FinalDefaultAttributeHasValueList() { - Assert.IsTrue(base.Contains(finalDefaultAttributeValues, "list"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(finalDefaultAttributeValues, "list"), "Attribute value 'list' missing."); } @@ -197,14 +197,14 @@ namespace XmlEditor.Tests.Schema [Test] public void MixedAttributeHasValueTrue() { - Assert.IsTrue(base.Contains(mixedAttributeValues, "true"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(mixedAttributeValues, "true"), "Attribute value 'true' missing."); } [Test] public void MaxOccursAttributeHasValueUnbounded() { - Assert.IsTrue(base.Contains(maxOccursAttributeValues, "unbounded"), + Assert.IsTrue(SchemaTestFixtureBase.Contains(maxOccursAttributeValues, "unbounded"), "Attribute value 'unbounded' missing."); } } diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/ResourceManager.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/ResourceManager.cs index a82cd1dd4f..3433e9fabc 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/ResourceManager.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/ResourceManager.cs @@ -49,8 +49,8 @@ namespace XmlEditor.Tests.Utils XmlTextReader reader = null; Assembly assembly = Assembly.GetAssembly(this.GetType()); - - Stream resourceStream = assembly.GetManifestResourceStream(fileName); + string resourceName = String.Concat("XmlEditor.Tests.Resources.", fileName); + Stream resourceStream = assembly.GetManifestResourceStream(resourceName); if (resourceStream != null) { reader = new XmlTextReader(resourceStream); } diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/SchemaIncludeTestFixtureHelper.cs b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/SchemaIncludeTestFixtureHelper.cs new file mode 100644 index 0000000000..29337f141f --- /dev/null +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/Utils/SchemaIncludeTestFixtureHelper.cs @@ -0,0 +1,90 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using ICSharpCode.XmlEditor; +using System; +using System.IO; +using System.Text; +using System.Xml; + +namespace XmlEditor.Tests.Utils +{ + /// + /// Helper class when testing a schema which includes + /// another schema. + /// + public class SchemaIncludeTestFixtureHelper + { + static string mainSchemaFileName = "main.xsd"; + static string includedSchemaFileName = "include.xsd"; + static readonly string schemaPath; + + SchemaIncludeTestFixtureHelper() + { + } + + static SchemaIncludeTestFixtureHelper() + { + schemaPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "XmlEditorTests"); + } + + /// + /// Creates a schema with the given filename + /// + /// Filename of the schema that will be + /// generated. + /// The schema xml + public static void CreateSchema(string fileName, string xml) + { + XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.UTF8); + writer.WriteRaw(xml); + writer.Close(); + } + + /// + /// Creates two schemas, one which references the other via an + /// xs:include. Both schemas will exist in the same folder. + /// + /// The main schema's xml. + /// The included schema's xml. + public static XmlSchemaCompletionData CreateSchemaCompletionDataObject(string mainSchema, string includedSchema) + { + if (!Directory.Exists(schemaPath)) { + Directory.CreateDirectory(schemaPath); + } + + CreateSchema(Path.Combine(schemaPath, mainSchemaFileName), mainSchema); + CreateSchema(Path.Combine(schemaPath, includedSchemaFileName), includedSchema); + + // Parse schema. + string schemaFileName = Path.Combine(schemaPath, mainSchemaFileName); + string baseUri = XmlSchemaCompletionData.GetUri(schemaFileName); + return new XmlSchemaCompletionData(baseUri, schemaFileName); + } + + /// + /// Removes any files generated for the test fixture. + /// + public static void FixtureTearDown() + { + // Delete the created schemas. + string fileName = Path.Combine(schemaPath, mainSchemaFileName); + if (File.Exists(fileName)) { + File.Delete(fileName); + } + + fileName = Path.Combine(schemaPath, includedSchemaFileName); + if (File.Exists(fileName)) { + File.Delete(fileName); + } + + if (Directory.Exists(schemaPath)) { + Directory.Delete(schemaPath); + } + } + } +} diff --git a/src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj b/src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj index e55a919fd4..38c9ff0d97 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj +++ b/src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj @@ -80,6 +80,11 @@ + + + + + diff --git a/src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln b/src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln index 499cc49308..642d9caabf 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln +++ b/src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 9.00 -# SharpDevelop 2.0.0.309 +# SharpDevelop 2.0.0.422 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor", "Project\XmlEditor.csproj", "{63B6CA43-58D0-4BF0-9D4F-1ABE4009E488}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor.Tests", "Test\XmlEditor.Tests.csproj", "{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}"