2
using MonoDevelop.XmlEditor;
8
namespace MonoDevelop.XmlEditor.Tests.Utils
11
/// Helper class when testing a schema which includes
14
public class SchemaIncludeTestFixtureHelper
16
static string mainSchemaFileName = "main.xsd";
17
static string includedSchemaFileName = "include.xsd";
18
static readonly string schemaPath;
20
SchemaIncludeTestFixtureHelper()
24
static SchemaIncludeTestFixtureHelper()
26
schemaPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "XmlEditorTests");
30
/// Creates a schema with the given filename
32
/// <param name="fileName">Filename of the schema that will be
33
/// generated.</param>
34
/// <param name="xml">The schema xml</param>
35
public static void CreateSchema(string fileName, string xml)
37
XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.UTF8);
43
/// Creates two schemas, one which references the other via an
44
/// xs:include. Both schemas will exist in the same folder.
46
/// <param name="mainSchema">The main schema's xml.</param>
47
/// <param name="includedSchema">The included schema's xml.</param>
48
public static XmlSchemaCompletionData CreateSchemaCompletionDataObject(string mainSchema, string includedSchema)
50
if (!Directory.Exists(schemaPath)) {
51
Directory.CreateDirectory(schemaPath);
54
CreateSchema(Path.Combine(schemaPath, mainSchemaFileName), mainSchema);
55
CreateSchema(Path.Combine(schemaPath, includedSchemaFileName), includedSchema);
58
string schemaFileName = Path.Combine(schemaPath, mainSchemaFileName);
59
string baseUri = XmlSchemaCompletionData.GetUri(schemaFileName);
60
return new XmlSchemaCompletionData(baseUri, schemaFileName);
64
/// Removes any files generated for the test fixture.
66
public static void FixtureTearDown()
68
// Delete the created schemas.
69
string fileName = Path.Combine(schemaPath, mainSchemaFileName);
70
if (File.Exists(fileName)) {
71
File.Delete(fileName);
74
fileName = Path.Combine(schemaPath, includedSchemaFileName);
75
if (File.Exists(fileName)) {
76
File.Delete(fileName);
79
if (Directory.Exists(schemaPath)) {
80
Directory.Delete(schemaPath);