// // 2002-2005 AlphaSierraPapa // GNU General Public License // // $Revision$ // using ICSharpCode.TextEditor.Gui.CompletionWindow; using ICSharpCode.XmlEditor; using NUnit.Framework; using System; using System.IO; namespace XmlEditor.Tests.Schema { /// /// Tests complex content extension elements. /// [TestFixture] public class ComplexContentExtensionTestFixture : SchemaTestFixtureBase { ICompletionData[] bodyChildElements; ICompletionData[] bodyAttributes; public override void FixtureInit() { XmlElementPath path = new XmlElementPath(); path.Elements.Add(new QualifiedName("body", "http://www.w3schools.com")); bodyChildElements = SchemaCompletionData.GetChildElementCompletionData(path); bodyAttributes = SchemaCompletionData.GetAttributeCompletionData(path); } [Test] public void TitleHasNoChildElements() { XmlElementPath path = new XmlElementPath(); 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, "Should be no child elements."); } [Test] public void TextHasNoChildElements() { XmlElementPath path = new XmlElementPath(); 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, "Should be no child elements."); } [Test] public void BodyHasTwoChildElements() { Assert.AreEqual(2, bodyChildElements.Length, "Should be two child elements."); } [Test] public void BodyChildElementIsText() { Assert.IsTrue(SchemaTestFixtureBase.Contains(bodyChildElements, "text"), "Should have a child element called text."); } [Test] public void BodyChildElementIsTitle() { Assert.IsTrue(SchemaTestFixtureBase.Contains(bodyChildElements, "title"), "Should have a child element called title."); } [Test] public void BodyAttributeCount() { Assert.AreEqual(1, bodyAttributes.Length, "Should be one attribute."); } [Test] public void BodyAttributeName() { Assert.IsTrue(SchemaTestFixtureBase.Contains(bodyAttributes, "id"), "Attribute id not found."); } protected override string GetSchema() { return "\r\n" + "\t\r\n" + "\t\t\r\n" + "\t\t\t\r\n" + "\t\t\t\r\n" + "\t\t\r\n" + "\t\r\n" + "\r\n" + "\t\r\n" + "\t\t\r\n" + "\t\t\t\r\n" + "\t\t\t\t\r\n" + "\t\t\t\t\t\r\n" + "\t\t\t\t\r\n" + "\t\t\t\r\n" + "\t\t\r\n" + "\t\r\n" + ""; } } }