2024-07-26 00:37:47 +02:00
|
|
|
using System.Xml;
|
2024-08-18 21:29:38 +02:00
|
|
|
using DotTiled.Model;
|
2024-07-26 00:37:47 +02:00
|
|
|
|
|
|
|
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 23:03:53 +02:00
|
|
|
var fullyQualifiedTestDataFile = $"DotTiled.Tests.{ConvertPathToAssemblyResourcePath(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)
|
|
|
|
{
|
2024-08-12 23:03:53 +02:00
|
|
|
var fullyQualifiedTestDataFile = $"DotTiled.Tests.{ConvertPathToAssemblyResourcePath(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-08-12 22:07:30 +02:00
|
|
|
|
2024-08-12 23:03:53 +02:00
|
|
|
private static string ConvertPathToAssemblyResourcePath(string path) =>
|
|
|
|
path.Replace("/", ".").Replace("\\", ".").Replace(" ", "_");
|
|
|
|
|
2024-08-12 22:33:00 +02:00
|
|
|
public static IEnumerable<object[]> MapTests =>
|
2024-08-12 22:07:30 +02:00
|
|
|
[
|
2024-08-24 22:06:14 +02:00
|
|
|
["Serialization/TestData/Map/default_map/default-map", (string f) => DefaultMap(), Array.Empty<ICustomTypeDefinition>()],
|
|
|
|
["Serialization/TestData/Map/map_with_common_props/map-with-common-props", (string f) => MapWithCommonProps(), Array.Empty<ICustomTypeDefinition>()],
|
2024-08-22 21:12:16 +02:00
|
|
|
["Serialization/TestData/Map/map_with_custom_type_props/map-with-custom-type-props", (string f) => MapWithCustomTypeProps(), MapWithCustomTypePropsCustomTypeDefinitions()],
|
2024-08-24 22:06:14 +02:00
|
|
|
["Serialization/TestData/Map/map_with_embedded_tileset/map-with-embedded-tileset", (string f) => MapWithEmbeddedTileset(), Array.Empty<ICustomTypeDefinition>()],
|
|
|
|
["Serialization/TestData/Map/map_with_external_tileset/map-with-external-tileset", (string f) => MapWithExternalTileset(f), Array.Empty<ICustomTypeDefinition>()],
|
|
|
|
["Serialization/TestData/Map/map_with_flippingflags/map-with-flippingflags", (string f) => MapWithFlippingFlags(f), Array.Empty<ICustomTypeDefinition>()],
|
|
|
|
["Serialization/TestData/Map/map_external_tileset_multi/map-external-tileset-multi", (string f) => MapExternalTilesetMulti(f), Array.Empty<ICustomTypeDefinition>()],
|
|
|
|
["Serialization/TestData/Map/map_external_tileset_wangset/map-external-tileset-wangset", (string f) => MapExternalTilesetWangset(f), Array.Empty<ICustomTypeDefinition>()],
|
|
|
|
["Serialization/TestData/Map/map_with_many_layers/map-with-many-layers", (string f) => MapWithManyLayers(f), Array.Empty<ICustomTypeDefinition>()],
|
2024-08-12 22:07:30 +02:00
|
|
|
];
|
2024-07-26 00:37:47 +02:00
|
|
|
}
|