//
//
//
//
// $Revision: 1683 $
//
using ICSharpCode.SharpDevelop.Editor;
using System;
using System.IO;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
namespace XmlEditor.Tests.Schema
{
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.
///
public static bool Contains(ICompletionItem[] items, string name)
{
bool Contains = false;
foreach (ICompletionItem data in items) {
if (data.Text == name) {
Contains = true;
break;
}
}
return Contains;
}
///
/// Checks whether the completion data specified by name has
/// the correct description.
///
public static bool ContainsDescription(ICompletionItem[] items, string name, string description)
{
bool Contains = false;
foreach (ICompletionItem data in items) {
if (data.Text == 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.
///
public static int GetItemCount(ICompletionItem[] items, string name)
{
int count = 0;
foreach (ICompletionItem data in items) {
if (data.Text == name) {
++count;
}
}
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);
}
}
}