blob: 16e56e185e15c1e96893361638c4caaacf727804 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
using MonoDevelop.Ide.CodeCompletion;
using MonoDevelop.Xml.Completion;
using NUnit.Framework;
using System;
using System.IO;
namespace MonoDevelop.Xml.Tests.Schema
{
[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>
public static bool Contains(CompletionDataList items, string name)
{
bool Contains = false;
foreach (var data in items) {
if (data.DisplayText == name) {
Contains = true;
break;
}
}
return Contains;
}
/// <summary>
/// Checks whether the completion data specified by name has
/// the correct description.
/// </summary>
public static bool ContainsDescription(CompletionDataList items, string name, string description)
{
bool Contains = false;
foreach (var data in items) {
if (data.DisplayText == name) {
//if (data.DisplayText == description) {
Contains = true;
break;
//}
}
}
return Contains;
}
/// <summary>
/// Gets a count of the number of occurrences of a particular name
/// in the completion data.
/// </summary>
public static int GetItemCount(CompletionDataList items, string name)
{
int count = 0;
foreach (var data in items) {
if (data.DisplayText == name) {
++count;
}
}
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);
}
}
}
|