Browse Source

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
shortcuts
Matt Ward 21 years ago
parent
commit
43a18fe66a
  1. 11
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionData.cs
  2. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.csproj
  3. 48
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Includes/AttributeGroupRefSchemaIncludeTestFixture.cs
  4. 48
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Includes/TwoElementSchemaIncludeTestFixture.cs
  5. 46
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Uri/GetUriTestFixture.cs
  6. 137
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AbstractElementTestFixture.cs
  7. 15
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeAnnotationTestFixture.cs
  8. 21
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeGroupRefTestFixture.cs
  9. 18
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeRefTestFixture.cs
  10. 15
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeValueAnnotationTestFixture.cs
  11. 13
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChildElementAttributesTestFixture.cs
  12. 21
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChoiceTestFixture.cs
  13. 23
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ComplexContentExtensionTestFixture.cs
  14. 15
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/DuplicateElementTestFixture.cs
  15. 12
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementAnnotationTestFixture.cs
  16. 13
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementRefAnnotationTestFixture.cs
  17. 15
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementWithAttributeSchemaTestFixture.cs
  18. 14
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/EnumAttributeValueTestFixture.cs
  19. 40
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ExtensionElementTestFixture.cs
  20. 19
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefCompositorTestFixture.cs
  21. 22
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefTestFixture.cs
  22. 6
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NamespaceCompletionTestFixture.cs
  23. 25
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedAttributeGroupRefTestFixture.cs
  24. 19
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedChoiceTestFixture.cs
  25. 15
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedElementSchemaTestFixture.cs
  26. 19
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedSequenceTestFixture.cs
  27. 33
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ReferencedElementsTestFixture.cs
  28. 33
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/RestrictionElementTestFixture.cs
  29. 122
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs
  30. 19
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SequencedChoiceTestFixture.cs
  31. 13
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SimpleContentWithAttributeTestFixture.cs
  32. 15
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SingleElementSchemaTestFixture.cs
  33. 25
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/TwoElementSchemaTestFixture.cs
  34. 30
      src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XsdSchemaTestFixture.cs
  35. 4
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/ResourceManager.cs
  36. 90
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/SchemaIncludeTestFixtureHelper.cs
  37. 5
      src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj
  38. 2
      src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln

11
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlSchemaCompletionData.cs

@ -998,15 +998,14 @@ namespace ICSharpCode.XmlEditor @@ -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));
}
}
}

2
src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.csproj

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6B717BD1-CD5E-498C-A42E-9E6A4584DC48}</ProjectGuid>
<ProjectGuid>{63B6CA43-58D0-4BF0-9D4F-1ABE4009E488}</ProjectGuid>
<RootNamespace>ICSharpCode.XmlEditor</RootNamespace>
<AssemblyName>XmlEditor</AssemblyName>
<OutputType>Library</OutputType>

48
src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Includes/AttributeGroupRefSchemaIncludeTestFixture.cs

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
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
{
/// <summary>
/// Tests that schemas referenced via xs:include elements are used when
/// generating completion data.
/// </summary>
[TestFixture]
public class AttributeGroupRefSchemaIncludeTestFixture : AttributeGroupRefTestFixture
{
[TestFixtureTearDown]
public void FixtureTearDown()
{
SchemaIncludeTestFixtureHelper.FixtureTearDown();
}
protected override XmlSchemaCompletionData CreateSchemaCompletionDataObject()
{
return SchemaIncludeTestFixtureHelper.CreateSchemaCompletionDataObject(GetMainSchema(), GetSchema());
}
string GetMainSchema()
{
return "<xs:schema \r\n" +
"targetNamespace=\"http://www.w3schools.com\" \r\n" +
"xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" \r\n" +
"elementFormDefault=\"qualified\">\r\n" +
"\t<xs:include schemaLocation=\"include.xsd\"/>\r\n" +
"</xs:schema>";
}
}
}

48
src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Includes/TwoElementSchemaIncludeTestFixture.cs

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
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
{
/// <summary>
/// Tests that schemas referenced via xs:include elements are used when
/// generating completion data.
/// </summary>
[TestFixture]
public class TwoElementSchemaIncludeTestFixture : TwoElementSchemaTestFixture
{
[TestFixtureTearDown]
public void FixtureTearDown()
{
SchemaIncludeTestFixtureHelper.FixtureTearDown();
}
protected override XmlSchemaCompletionData CreateSchemaCompletionDataObject()
{
return SchemaIncludeTestFixtureHelper.CreateSchemaCompletionDataObject(GetMainSchema(), GetSchema());
}
string GetMainSchema()
{
return "<xs:schema \r\n" +
"targetNamespace=\"http://www.w3schools.com\" \r\n" +
"xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" \r\n" +
"elementFormDefault=\"qualified\">\r\n" +
"\t<xs:include schemaLocation=\"include.xsd\"/>\r\n" +
"</xs:schema>";
}
}
}

46
src/AddIns/DisplayBindings/XmlEditor/Test/Schema.Uri/GetUriTestFixture.cs

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
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
{
/// <summary>
/// Tests the <see cref="XmlSchemaCompletionData.GetUri"/> method.
/// </summary>
[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));
}
}
}

137
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AbstractElementTestFixture.cs

@ -0,0 +1,137 @@ @@ -0,0 +1,137 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 318 $</version>
// </file>
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
/// <summary>
/// Tests elements that are abstract and require substitution groups.
/// </summary>
[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 "<xs:schema targetNamespace=\"http://foo\" xmlns:foo=\"http://foo\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\">\r\n" +
" <xs:element name=\"project\">\r\n" +
" <xs:complexType>\r\n" +
" <xs:sequence>\r\n" +
" <xs:group ref=\"foo:projectItems\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\r\n" +
" </xs:sequence>\r\n" +
" </xs:complexType>\r\n" +
" </xs:element>\r\n" +
"\r\n" +
" <xs:group name=\"projectItems\">\r\n" +
" <xs:choice>\r\n" +
" <xs:element name=\"items\" type=\"foo:itemGroupType\"/>\r\n" +
" <xs:element name=\"message\" type=\"xs:string\"/>\r\n" +
" </xs:choice>\r\n" +
" </xs:group>\r\n" +
"\r\n" +
" <xs:complexType name=\"itemGroupType\">\r\n" +
" <xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
" <xs:element ref=\"foo:item\"/>\r\n" +
" </xs:sequence>\r\n" +
" <xs:attribute name=\"name\" type=\"xs:string\" use=\"optional\"/> \r\n" +
" </xs:complexType>\r\n" +
"\r\n" +
" <xs:element name=\"item\" type=\"foo:itemType\" abstract=\"true\"/>\r\n" +
"\r\n" +
"<xs:complexType name=\"itemType\">\r\n" +
" <xs:attribute name=\"name\" type=\"xs:string\" use=\"optional\"/> \r\n" +
" </xs:complexType>\r\n" +
"\r\n" +
" <xs:element name=\"reference\" substitutionGroup=\"foo:item\">\r\n" +
" <xs:complexType>\r\n" +
" <xs:complexContent>\r\n" +
" <xs:extension base=\"foo:itemType\">\r\n" +
" <xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
" <xs:choice>\r\n" +
" <xs:element name=\"name\"/>\r\n" +
" <xs:element name=\"location\"/> \r\n" +
" </xs:choice>\r\n" +
" </xs:sequence>\r\n" +
" <xs:attribute name=\"description\" type=\"xs:string\"/>\r\n" +
" </xs:extension>\r\n" +
" </xs:complexContent>\r\n" +
" </xs:complexType>\r\n" +
" </xs:element>\r\n" +
"\r\n" +
" <xs:element name=\"file\" substitutionGroup=\"foo:item\">\r\n" +
" <xs:complexType>\r\n" +
" <xs:complexContent>\r\n" +
" <xs:extension base=\"foo:itemType\">\r\n" +
" <xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n" +
" <xs:choice>\r\n" +
" <xs:element name=\"name\"/>\r\n" +
" <xs:element name=\"attributes\"/>\r\n" +
" </xs:choice>\r\n" +
" </xs:sequence>\r\n" +
" <xs:attribute name=\"type\" type=\"xs:string\"/>\r\n" +
" </xs:extension>\r\n" +
" </xs:complexContent>\r\n" +
" </xs:complexType>\r\n" +
" </xs:element>\r\n" +
"</xs:schema>";
}
}
}

15
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeAnnotationTestFixture.cs

@ -21,23 +21,18 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -52,7 +47,7 @@ namespace XmlEditor.Tests.Schema
Assert.AreEqual("Documentation for bar attribute.", barAttributeCompletionData[0].Description);
}
string GetSchema()
protected override string GetSchema()
{
return "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://foo.com\" xmlns=\"http://foo.com\" elementFormDefault=\"qualified\">\r\n" +
"\t<xs:element name=\"foo\">\r\n" +

21
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeGroupRefTestFixture.cs

@ -19,18 +19,13 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\" elementFormDefault=\"qualified\">\r\n" +
"<xs:attributeGroup name=\"coreattrs\">" +

18
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeRefTestFixture.cs

@ -19,17 +19,13 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 "<xs:schema version=\"1.0\" xml:lang=\"en\"\r\n" +
" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n" +

15
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/AttributeValueAnnotationTestFixture.cs

@ -21,28 +21,23 @@ namespace XmlEditor.Tests.Schema @@ -21,28 +21,23 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class AttributeValueAnnotationTestFixture : SchemaTestFixtureBase
{
XmlSchemaCompletionData schemaCompletionData;
ICompletionData[] barAttributeValuesCompletionData;
[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"));
barAttributeValuesCompletionData = schemaCompletionData.GetAttributeValueCompletionData(path, "bar");
barAttributeValuesCompletionData = SchemaCompletionData.GetAttributeValueCompletionData(path, "bar");
}
[Test]
public void BarAttributeValueDefaultDocumentation()
{
Assert.IsTrue(base.ContainsDescription(barAttributeValuesCompletionData, "default", "Default attribute value info."),
Assert.IsTrue(SchemaTestFixtureBase.ContainsDescription(barAttributeValuesCompletionData, "default", "Default attribute value info."),
"Description for attribute value 'default' is incorrect.");
}
string GetSchema()
protected override string GetSchema()
{
return "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n" +
"\ttargetNamespace=\"http://foo.com\"\r\n" +

13
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChildElementAttributesTestFixture.cs

@ -19,20 +19,15 @@ namespace XmlEditor.Tests.Schema @@ -19,20 +19,15 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class ChildElementAttributesTestFixture : 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("project", "http://nant.sf.net//nant-0.84.xsd"));
path.Elements.Add(new QualifiedName("attrib", "http://nant.sf.net//nant-0.84.xsd"));
attributes = schemaCompletionData.GetAttributeCompletionData(path);
attributes = SchemaCompletionData.GetAttributeCompletionData(path);
}
[Test]
@ -44,11 +39,11 @@ namespace XmlEditor.Tests.Schema @@ -44,11 +39,11 @@ namespace XmlEditor.Tests.Schema
[Test]
public void FileAttribute()
{
Assert.IsTrue(base.Contains(attributes, "file"),
Assert.IsTrue(SchemaTestFixtureBase.Contains(attributes, "file"),
"Attribute file does not exist.");
}
string GetSchema()
protected override string GetSchema()
{
return "<xs:schema xmlns:vs=\"urn:schemas-microsoft-com:HTML-Intellisense\" xmlns:nant=\"http://nant.sf.net//nant-0.84.xsd\" targetNamespace=\"http://nant.sf.net//nant-0.84.xsd\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\r\n" +
" <xs:element name=\"project\">\r\n" +

21
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ChoiceTestFixture.cs

@ -20,19 +20,14 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 @@ -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 @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\" elementFormDefault=\"qualified\">\r\n" +
"\t<xs:element name=\"note\">\r\n" +

23
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ComplexContentExtensionTestFixture.cs

@ -19,21 +19,16 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\" elementFormDefault=\"qualified\">\r\n" +
"\t<xs:complexType name=\"Block\">\r\n" +

15
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/DuplicateElementTestFixture.cs

@ -19,19 +19,14 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 "<xs:schema version=\"1.0\" xml:lang=\"en\"\r\n" +
" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n" +

12
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementAnnotationTestFixture.cs

@ -21,21 +21,17 @@ namespace XmlEditor.Tests.Schema @@ -21,21 +21,17 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class ElementAnnotationTestFixture : SchemaTestFixtureBase
{
XmlSchemaCompletionData schemaCompletionData;
ICompletionData[] fooChildElementCompletionData;
ICompletionData[] rootElementCompletionData;
[TestFixtureSetUp]
public void FixtureInit()
public override void FixtureInit()
{
StringReader reader = new StringReader(GetSchema());
schemaCompletionData = new XmlSchemaCompletionData(reader);
rootElementCompletionData = schemaCompletionData.GetElementCompletionData();
rootElementCompletionData = SchemaCompletionData.GetElementCompletionData();
XmlElementPath path = new XmlElementPath();
path.Elements.Add(new QualifiedName("foo", "http://foo.com"));
fooChildElementCompletionData = schemaCompletionData.GetChildElementCompletionData(path);
fooChildElementCompletionData = SchemaCompletionData.GetChildElementCompletionData(path);
}
[Test]
@ -50,7 +46,7 @@ namespace XmlEditor.Tests.Schema @@ -50,7 +46,7 @@ namespace XmlEditor.Tests.Schema
Assert.AreEqual("Documentation for bar element.", fooChildElementCompletionData[0].Description);
}
string GetSchema()
protected override string GetSchema()
{
return "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://foo.com\" xmlns=\"http://foo.com\" elementFormDefault=\"qualified\">\r\n" +
"\t<xs:element name=\"foo\">\r\n" +

13
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementRefAnnotationTestFixture.cs

@ -21,29 +21,24 @@ namespace XmlEditor.Tests.Schema @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://foo.com\" xmlns=\"http://foo.com\">\r\n" +
"\t<xs:element name=\"foo\">\r\n" +

15
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ElementWithAttributeSchemaTestFixture.cs

@ -17,22 +17,17 @@ namespace XmlEditor.Tests.Schema @@ -17,22 +17,17 @@ namespace XmlEditor.Tests.Schema
/// Element that has a single attribute.
/// </summary>
[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 @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\" elementFormDefault=\"qualified\">\r\n" +
" <xs:element name=\"note\">\r\n" +

14
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/EnumAttributeValueTestFixture.cs

@ -19,30 +19,26 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -52,7 +48,7 @@ namespace XmlEditor.Tests.Schema
Assert.AreEqual(2, attributeValues.Length, "Expecting 2 attribute values.");
}
string GetSchema()
protected override string GetSchema()
{
return "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://foo.com\" targetNamespace=\"http://foo.com\" elementFormDefault=\"qualified\">\r\n" +
"\t<xs:element name=\"foo\">\r\n" +

40
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ExtensionElementTestFixture.cs

@ -19,7 +19,6 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 "<xs:schema targetNamespace=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" version=\"1.0\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xml:lang=\"EN\">\r\n" +
"\r\n" +

19
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefCompositorTestFixture.cs

@ -23,24 +23,19 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://foo\" xmlns=\"http://foo\" elementFormDefault=\"qualified\">\r\n" +
"\t<xs:element name=\"root\">\r\n" +

22
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/GroupRefTestFixture.cs

@ -19,24 +19,20 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 "<xs:schema version=\"1.0\" xml:lang=\"en\"\r\n" +
" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n" +

6
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NamespaceCompletionTestFixture.cs

@ -18,7 +18,7 @@ namespace XmlEditor.Tests.Schema @@ -18,7 +18,7 @@ namespace XmlEditor.Tests.Schema
/// namespaces it holds.
/// </summary>
[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 @@ -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)

25
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedAttributeGroupRefTestFixture.cs

@ -19,18 +19,13 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\" elementFormDefault=\"qualified\">\r\n" +
"<xs:attributeGroup name=\"coreattrs\">" +

19
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedChoiceTestFixture.cs

@ -20,25 +20,20 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\" elementFormDefault=\"qualified\">\r\n" +
"\t<xs:element name=\"note\">\r\n" +

15
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedElementSchemaTestFixture.cs

@ -16,20 +16,15 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\" elementFormDefault=\"qualified\">\r\n" +
"\t<xs:element name=\"note\">\r\n" +

19
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/NestedSequenceTestFixture.cs

@ -20,18 +20,13 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 @@ -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 @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\" elementFormDefault=\"qualified\">\r\n" +
"\t<xs:element name=\"note\">\r\n" +

33
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/ReferencedElementsTestFixture.cs

@ -16,31 +16,26 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\">\r\n" +
"\r\n" +

33
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/RestrictionElementTestFixture.cs

@ -19,83 +19,78 @@ namespace XmlEditor.Tests.Schema @@ -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 "<xs:schema targetNamespace=\"http://www.w3.org/2001/XMLSchema\" blockDefault=\"#all\" elementFormDefault=\"qualified\" version=\"1.0\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xml:lang=\"EN\" xmlns:hfp=\"http://www.w3.org/2001/XMLSchema-hasFacetAndProperty\">\r\n" +
"\r\n" +

122
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SchemaTestFixtureBase.cs

@ -6,17 +6,112 @@ @@ -6,17 +6,112 @@
// </file>
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
namespace XmlEditor.Tests.Schema
{
// public abstract class SchemaTestFixtureBase
// {
// /// <summary>
// /// Checks whether the specified name exists in the completion data.
// /// </summary>
// 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;
// }
//
// /// <summary>
// /// Checks whether the completion data specified by name has
// /// the correct description.
// /// </summary>
// 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;
// }
//
// /// <summary>
// /// Gets a count of the number of occurrences of a particular name
// /// in the completion data.
// /// </summary>
// 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;
/// <summary>
/// Gets the <see cref="XmlSchemaCompletionData"/> object generated
/// by this class.
/// </summary>
/// <remarks>This object will be null until the <see cref="FixtureInitBase"/>
/// has been run.</remarks>
public XmlSchemaCompletionData SchemaCompletionData {
get {
return schemaCompletionData;
}
}
/// <summary>
/// Creates the <see cref="XmlSchemaCompletionData"/> object from
/// the derived class's schema.
/// </summary>
/// <remarks>Calls <see cref="FixtureInit"/> at the end of the method.
/// </remarks>
[TestFixtureSetUp]
public void FixtureInitBase()
{
schemaCompletionData = CreateSchemaCompletionDataObject();
FixtureInit();
}
/// <summary>
/// Method overridden by derived class so it can execute its own
/// fixture initialisation.
/// </summary>
public virtual void FixtureInit()
{
}
/// <summary>
/// Checks whether the specified name exists in the completion data.
/// </summary>
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 @@ -34,7 +129,7 @@ namespace XmlEditor.Tests.Schema
/// Checks whether the completion data specified by name has
/// the correct description.
/// </summary>
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 @@ -54,7 +149,7 @@ namespace XmlEditor.Tests.Schema
/// Gets a count of the number of occurrences of a particular name
/// in the completion data.
/// </summary>
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 @@ -66,5 +161,24 @@ namespace XmlEditor.Tests.Schema
return count;
}
/// <summary>
/// Returns the schema that will be used in this test fixture.
/// </summary>
/// <returns></returns>
protected virtual string GetSchema()
{
return String.Empty;
}
/// <summary>
/// Creates an <see cref="XmlSchemaCompletionData"/> object that
/// will be used in the test fixture.
/// </summary>
protected virtual XmlSchemaCompletionData CreateSchemaCompletionDataObject()
{
StringReader reader = new StringReader(GetSchema());
return new XmlSchemaCompletionData(reader);
}
}
}

19
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SequencedChoiceTestFixture.cs

@ -20,19 +20,14 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 @@ -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 @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.w3schools.com\" xmlns=\"http://www.w3schools.com\" elementFormDefault=\"qualified\">\r\n" +
"\t<xs:element name=\"note\">\r\n" +

13
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SimpleContentWithAttributeTestFixture.cs

@ -19,29 +19,24 @@ namespace XmlEditor.Tests.Schema @@ -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 "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n" +
"\ttargetNamespace=\"http://foo.com\"\r\n" +

15
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/SingleElementSchemaTestFixture.cs

@ -20,31 +20,26 @@ namespace XmlEditor.Tests.Schema @@ -20,31 +20,26 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class SingleElementSchemaTestFixture : SchemaTestFixtureBase
{
XmlSchemaCompletionData schemaCompletionData;
ICompletionData[] childElementCompletionData;
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);
SchemaCompletionData.GetAttributeCompletionData(path);
childElementCompletionData =
schemaCompletionData.GetChildElementCompletionData(path);
SchemaCompletionData.GetChildElementCompletionData(path);
}
[Test]
public void NamespaceUri()
{
Assert.AreEqual("http://www.w3schools.com",
schemaCompletionData.NamespaceUri,
SchemaCompletionData.NamespaceUri,
"Unexpected namespace.");
}
@ -62,7 +57,7 @@ namespace XmlEditor.Tests.Schema @@ -62,7 +57,7 @@ namespace XmlEditor.Tests.Schema
"Not expecting any child elements.");
}
string GetSchema()
protected override string GetSchema()
{
return "<?xml version=\"1.0\"?>\r\n" +
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\r\n" +

25
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/TwoElementSchemaTestFixture.cs

@ -20,16 +20,11 @@ namespace XmlEditor.Tests.Schema @@ -20,16 +20,11 @@ namespace XmlEditor.Tests.Schema
[TestFixture]
public class TwoElementSchemaTestFixture : SchemaTestFixtureBase
{
XmlSchemaCompletionData schemaCompletionData;
XmlElementPath noteElementPath;
XmlElementPath textElementPath;
[TestFixtureSetUp]
public void FixtureInit()
public override void FixtureInit()
{
StringReader reader = new StringReader(GetSchema());
schemaCompletionData = new XmlSchemaCompletionData(reader);
// Note element path.
noteElementPath = new XmlElementPath();
QualifiedName noteQualifiedName = new QualifiedName("note", "http://www.w3schools.com");
@ -44,7 +39,7 @@ namespace XmlEditor.Tests.Schema @@ -44,7 +39,7 @@ namespace XmlEditor.Tests.Schema
[Test]
public void TextElementHasOneAttribute()
{
ICompletionData[] attributesCompletionData = schemaCompletionData.GetAttributeCompletionData(textElementPath);
ICompletionData[] attributesCompletionData = SchemaCompletionData.GetAttributeCompletionData(textElementPath);
Assert.AreEqual(1, attributesCompletionData.Length,
"Should have 1 text attribute.");
@ -53,8 +48,8 @@ namespace XmlEditor.Tests.Schema @@ -53,8 +48,8 @@ namespace XmlEditor.Tests.Schema
[Test]
public void TextElementAttributeName()
{
ICompletionData[] attributesCompletionData = schemaCompletionData.GetAttributeCompletionData(textElementPath);
Assert.IsTrue(base.Contains(attributesCompletionData, "foo"),
ICompletionData[] attributesCompletionData = SchemaCompletionData.GetAttributeCompletionData(textElementPath);
Assert.IsTrue(SchemaTestFixtureBase.Contains(attributesCompletionData, "foo"),
"Unexpected text attribute name.");
}
@ -62,7 +57,7 @@ namespace XmlEditor.Tests.Schema @@ -62,7 +57,7 @@ namespace XmlEditor.Tests.Schema
public void NoteElementHasChildElement()
{
ICompletionData[] childElementCompletionData
= schemaCompletionData.GetChildElementCompletionData(noteElementPath);
= SchemaCompletionData.GetChildElementCompletionData(noteElementPath);
Assert.AreEqual(1, childElementCompletionData.Length,
"Should be one child.");
@ -72,7 +67,7 @@ namespace XmlEditor.Tests.Schema @@ -72,7 +67,7 @@ namespace XmlEditor.Tests.Schema
public void NoteElementHasNoAttributes()
{
ICompletionData[] attributeCompletionData
= schemaCompletionData.GetAttributeCompletionData(noteElementPath);
= SchemaCompletionData.GetAttributeCompletionData(noteElementPath);
Assert.AreEqual(0, attributeCompletionData.Length,
"Should no attributes.");
@ -82,7 +77,7 @@ namespace XmlEditor.Tests.Schema @@ -82,7 +77,7 @@ namespace XmlEditor.Tests.Schema
public void OneRootElement()
{
ICompletionData[] elementCompletionData
= schemaCompletionData.GetElementCompletionData();
= SchemaCompletionData.GetElementCompletionData();
Assert.AreEqual(1, elementCompletionData.Length, "Should be 1 root element.");
}
@ -91,13 +86,13 @@ namespace XmlEditor.Tests.Schema @@ -91,13 +86,13 @@ namespace XmlEditor.Tests.Schema
public void RootElementIsNote()
{
ICompletionData[] elementCompletionData
= schemaCompletionData.GetElementCompletionData();
= SchemaCompletionData.GetElementCompletionData();
Assert.IsTrue(Contains(elementCompletionData, "note"),
"Should be called note.");
}
}
string GetSchema()
protected override string GetSchema()
{
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" +
"\t<xs:element name=\"note\">\r\n" +

30
src/AddIns/DisplayBindings/XmlEditor/Test/Schema/XsdSchemaTestFixture.cs

@ -19,7 +19,7 @@ namespace XmlEditor.Tests.Schema @@ -19,7 +19,7 @@ namespace XmlEditor.Tests.Schema
/// Tests the xsd schema.
/// </summary>
[TestFixture]
public class XsdSchemaTestFixture : SchemaTestFixtureBase
public class XsdSchemaTestFixture
{
XmlSchemaCompletionData schemaCompletionData;
XmlElementPath choicePath;
@ -101,14 +101,14 @@ namespace XmlEditor.Tests.Schema @@ -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 @@ -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 @@ -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 @@ -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 @@ -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.");
}
}

4
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/ResourceManager.cs

@ -49,8 +49,8 @@ namespace XmlEditor.Tests.Utils @@ -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);
}

90
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/SchemaIncludeTestFixtureHelper.cs

@ -0,0 +1,90 @@ @@ -0,0 +1,90 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.XmlEditor;
using System;
using System.IO;
using System.Text;
using System.Xml;
namespace XmlEditor.Tests.Utils
{
/// <summary>
/// Helper class when testing a schema which includes
/// another schema.
/// </summary>
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");
}
/// <summary>
/// Creates a schema with the given filename
/// </summary>
/// <param name="fileName">Filename of the schema that will be
/// generated.</param>
/// <param name="xml">The schema xml</param>
public static void CreateSchema(string fileName, string xml)
{
XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.UTF8);
writer.WriteRaw(xml);
writer.Close();
}
/// <summary>
/// Creates two schemas, one which references the other via an
/// xs:include. Both schemas will exist in the same folder.
/// </summary>
/// <param name="mainSchema">The main schema's xml.</param>
/// <param name="includedSchema">The included schema's xml.</param>
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);
}
/// <summary>
/// Removes any files generated for the test fixture.
/// </summary>
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);
}
}
}
}

5
src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj

@ -80,6 +80,11 @@ @@ -80,6 +80,11 @@
<Compile Include="Schema\SimpleContentWithAttributeTestFixture.cs" />
<EmbeddedResource Include="Resources\xhtml1-strict-modified.xsd" />
<EmbeddedResource Include="Resources\XMLSchema.xsd" />
<Compile Include="Schema.Includes\AttributeGroupRefSchemaIncludeTestFixture.cs" />
<Compile Include="Schema.Includes\TwoElementSchemaIncludeTestFixture.cs" />
<Compile Include="Schema.Uri\GetUriTestFixture.cs" />
<Compile Include="Schema\AbstractElementTestFixture.cs" />
<Compile Include="Utils\SchemaIncludeTestFixtureHelper.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Schema\" />

2
src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln

@ -1,5 +1,5 @@ @@ -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}"

Loading…
Cancel
Save