2024-07-26 00:37:47 +02:00
|
|
|
using System.Xml;
|
|
|
|
|
|
|
|
namespace DotTiled.Tests;
|
|
|
|
|
2024-08-09 23:12:45 +02:00
|
|
|
public static partial class TestData
|
2024-07-26 00:37:47 +02:00
|
|
|
{
|
2024-08-03 14:26:09 +02:00
|
|
|
public static XmlReader GetXmlReaderFor(string testDataFile)
|
2024-07-26 00:37:47 +02:00
|
|
|
{
|
2024-08-12 21:24:09 +02:00
|
|
|
var names = typeof(TestData).Assembly.GetManifestResourceNames();
|
|
|
|
|
2024-07-26 00:37:47 +02:00
|
|
|
var fullyQualifiedTestDataFile = $"DotTiled.Tests.{testDataFile}";
|
2024-08-09 23:12:45 +02:00
|
|
|
using var stream = typeof(TestData).Assembly.GetManifestResourceStream(fullyQualifiedTestDataFile)
|
2024-07-26 00:37:47 +02:00
|
|
|
?? throw new ArgumentException($"Test data file '{fullyQualifiedTestDataFile}' not found");
|
|
|
|
|
|
|
|
using var stringReader = new StreamReader(stream);
|
|
|
|
var xml = stringReader.ReadToEnd();
|
|
|
|
var xmlStringReader = new StringReader(xml);
|
|
|
|
return XmlReader.Create(xmlStringReader);
|
|
|
|
}
|
2024-07-27 23:53:05 +02:00
|
|
|
|
|
|
|
public static string GetRawStringFor(string testDataFile)
|
|
|
|
{
|
|
|
|
var fullyQualifiedTestDataFile = $"DotTiled.Tests.{testDataFile}";
|
2024-08-09 23:12:45 +02:00
|
|
|
using var stream = typeof(TestData).Assembly.GetManifestResourceStream(fullyQualifiedTestDataFile)
|
2024-07-27 23:53:05 +02:00
|
|
|
?? throw new ArgumentException($"Test data file '{fullyQualifiedTestDataFile}' not found");
|
|
|
|
|
|
|
|
using var stringReader = new StreamReader(stream);
|
|
|
|
return stringReader.ReadToEnd();
|
|
|
|
}
|
2024-07-26 00:37:47 +02:00
|
|
|
}
|