Remove old maps from tests and seperate model more

This commit is contained in:
Daniel Cronqvist 2024-08-12 21:24:09 +02:00
parent 33f1f4dcb7
commit 4aebf1d67b
43 changed files with 290 additions and 1296 deletions

View file

@ -2,44 +2,9 @@ namespace DotTiled.Tests;
public partial class TmjMapReaderTests
{
public static IEnumerable<object[]> DeserializeMap_ValidTmjNoExternalTilesets_ReturnsMapWithoutThrowing_Data =>
[
["Serialization.TestData.Map.empty-map-csv.tmj", TestData.EmptyMapWithEncodingAndCompression(DataEncoding.Csv, null)],
["Serialization.TestData.Map.empty-map-base64.tmj", TestData.EmptyMapWithEncodingAndCompression(DataEncoding.Base64, null)],
["Serialization.TestData.Map.empty-map-base64-gzip.tmj", TestData.EmptyMapWithEncodingAndCompression(DataEncoding.Base64, DataCompression.GZip)],
["Serialization.TestData.Map.empty-map-base64-zlib.tmj", TestData.EmptyMapWithEncodingAndCompression(DataEncoding.Base64, DataCompression.ZLib)],
["Serialization.TestData.Map.simple-tileset-embed.tmj", TestData.SimpleMapWithEmbeddedTileset()],
["Serialization.TestData.Map.empty-map-properties.tmj", TestData.EmptyMapWithProperties()],
];
[Theory]
[MemberData(nameof(DeserializeMap_ValidTmjNoExternalTilesets_ReturnsMapWithoutThrowing_Data))]
public void TmxMapReaderReadMap_ValidTmjNoExternalTilesets_ReturnsMapThatEqualsExpected(string testDataFile, Map expectedMap)
{
// Arrange
var json = TestData.GetRawStringFor(testDataFile);
static Template ResolveTemplate(string source)
{
throw new NotSupportedException("External templates are not supported in this test.");
}
static Tileset ResolveTileset(string source)
{
throw new NotSupportedException("External tilesets are not supported in this test.");
}
using var mapReader = new TmjMapReader(json, ResolveTileset, ResolveTemplate, []);
// Act
var map = mapReader.ReadMap();
// Assert
Assert.NotNull(map);
DotTiledAssert.AssertMap(expectedMap, map);
}
public static IEnumerable<object[]> DeserializeMap_ValidTmjExternalTilesetsAndTemplates_ReturnsMapThatEqualsExpected_Data =>
[
["Serialization.TestData.Map.map-with-object-template.tmj", TestData.MapWithObjectTemplate("tj")],
["Serialization.TestData.Map.map-with-group.tmj", TestData.MapWithGroup()],
["Serialization.TestData.Map.default_map.default-map.tmj", TestData.DefaultMap()]
];
[Theory]