Add test data that fails due to bug from reported issue

This commit is contained in:
Daniel Cronqvist 2025-04-28 20:11:19 +02:00
parent aa9d8498e8
commit 81277fdaf1
10 changed files with 325 additions and 0 deletions

View file

@ -315,4 +315,39 @@ public class LoaderTests
// Assert
DotTiledAssert.AssertProperties(customClassDefinition.Members, result.Properties);
}
public static IEnumerable<object[]> Maps => TestData.MapTests;
[Theory]
[MemberData(nameof(Maps))]
public void LoadMap_ValidFilesExternalTilesetsAndTemplatesWithCache_ReturnsMapThatEqualsExpected(
string testDataFile,
Func<string, Map> expectedMap,
IReadOnlyCollection<ICustomTypeDefinition> customTypeDefinitions)
{
// Arrange
string[] fileFormats = [".tmx", ".tmj"];
foreach (var fileFormat in fileFormats)
{
var testDataFileWithFormat = testDataFile + fileFormat;
var resourceReader = Substitute.For<IResourceReader>();
resourceReader.Read(Arg.Any<string>()).Returns(callInfo =>
{
var filePath = callInfo.Arg<string>();
return TestData.GetRawStringFor(filePath);
});
var loader = Loader.DefaultWith(
resourceReader: resourceReader,
customTypeDefinitions: customTypeDefinitions);
// Act
var map = loader.LoadMap(testDataFileWithFormat);
// Assert
Assert.NotNull(map);
DotTiledAssert.AssertMap(expectedMap(fileFormat[1..]), map);
}
}
}

View file

@ -34,6 +34,7 @@ public static partial class TestData
public static IEnumerable<object[]> MapTests =>
[
[GetMapPath("default-map"), (string f) => DefaultMap(), Array.Empty<ICustomTypeDefinition>()],
[GetMapPath("map-duplicate-object-id-bug"), (string f) => MapDuplicateObjectIdBug(f), Array.Empty<ICustomTypeDefinition>()],
[GetMapPath("map-with-common-props"), (string f) => MapWithCommonProps(), Array.Empty<ICustomTypeDefinition>()],
[GetMapPath("map-with-custom-type-props"), (string f) => MapWithCustomTypeProps(), MapWithCustomTypePropsCustomTypeDefinitions()],
[GetMapPath("map-with-custom-type-props-without-defs"), (string f) => MapWithCustomTypePropsWithoutDefs(), Array.Empty<ICustomTypeDefinition>()],