#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

89 lines
2.8 KiB

// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision: 915 $</version>
// </file>
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.Schema
{
/// <summary>
/// Tests that nested schema choice elements are handled.
/// This happens in the NAnt schema 0.85.
/// </summary>
[TestFixture]
public class ChoiceTestFixture : SchemaTestFixtureBase
{
ICompletionItem[] noteChildElements;
public override void FixtureInit()
{
XmlElementPath path = new XmlElementPath();
path.Elements.Add(new QualifiedName("note", "http://www.w3schools.com"));
noteChildElements = SchemaCompletionData.GetChildElementCompletionData(path);
}
[Test]
public void TitleHasNoChildElements()
{
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,
"Should be no child elements.");
}
[Test]
public void TextHasNoChildElements()
{
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,
"Should be no child elements.");
}
[Test]
public void NoteHasTwoChildElements()
{
Assert.AreEqual(2, noteChildElements.Length,
"Should be two child elements.");
}
[Test]
public void NoteChildElementIsText()
{
Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "text"),
"Should have a child element called text.");
}
[Test]
public void NoteChildElementIsTitle()
{
Assert.IsTrue(SchemaTestFixtureBase.Contains(noteChildElements, "title"),
"Should have a child element called title.");
}
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" +
"\t\t<xs:complexType> \r\n" +
"\t\t\t<xs:choice>\r\n" +
"\t\t\t\t<xs:element name=\"title\" type=\"xs:string\"/>\r\n" +
"\t\t\t\t<xs:element name=\"text\" type=\"xs:string\"/>\r\n" +
"\t\t\t</xs:choice>\r\n" +
"\t\t</xs:complexType>\r\n" +
"\t</xs:element>\r\n" +
"</xs:schema>";
}
}
}