1
using ICSharpCode.NRefactory.Completion;
2
using MonoDevelop.Ide.CodeCompletion;
3
using MonoDevelop.Xml.Completion;
8
namespace MonoDevelop.Xml.Tests.Schema
11
public abstract class SchemaTestFixtureBase
13
XmlSchemaCompletionData schemaCompletionData;
16
/// Gets the <see cref="XmlSchemaCompletionData"/> object generated
19
/// <remarks>This object will be null until the <see cref="FixtureInitBase"/>
20
/// has been run.</remarks>
21
public XmlSchemaCompletionData SchemaCompletionData {
23
return schemaCompletionData;
28
/// Creates the <see cref="XmlSchemaCompletionData"/> object from
29
/// the derived class's schema.
31
/// <remarks>Calls <see cref="FixtureInit"/> at the end of the method.
34
public void FixtureInitBase()
36
schemaCompletionData = CreateSchemaCompletionDataObject();
41
/// Method overridden by derived class so it can execute its own
42
/// fixture initialisation.
44
public virtual void FixtureInit()
49
/// Checks whether the specified name exists in the completion data.
51
public static bool Contains(CompletionDataList items, string name)
53
bool Contains = false;
55
foreach (ICompletionData data in items) {
56
if (data.DisplayText == name) {
66
/// Checks whether the completion data specified by name has
67
/// the correct description.
69
public static bool ContainsDescription(CompletionDataList items, string name, string description)
71
bool Contains = false;
73
foreach (ICompletionData data in items) {
74
if (data.DisplayText == name) {
75
if (data.Description == description) {
86
/// Gets a count of the number of occurrences of a particular name
87
/// in the completion data.
89
public static int GetItemCount(CompletionDataList items, string name)
93
foreach (ICompletionData data in items) {
94
if (data.DisplayText == name) {
103
/// Returns the schema that will be used in this test fixture.
105
/// <returns></returns>
106
protected virtual string GetSchema()
112
/// Creates an <see cref="XmlSchemaCompletionData"/> object that
113
/// will be used in the test fixture.
115
protected virtual XmlSchemaCompletionData CreateSchemaCompletionDataObject()
117
StringReader reader = new StringReader(GetSchema());
118
return new XmlSchemaCompletionData(reader);