Skip to content
This repository was archived by the owner on Jul 3, 2025. It is now read-only.

Commit ed78ccf

Browse files
authored
Merge pull request #1 from vonhoff/v1.0.2
Bug fixes, updated packages.
2 parents 81e6f7c + 7214628 commit ed78ccf

17 files changed

+102
-124
lines changed

Animation2Tilemap.Test/CommandLineOptions/HeightOptionTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.CommandLine;
2-
using Xunit;
32
using Animation2Tilemap.CommandLineOptions;
43

54
namespace Animation2Tilemap.Test.CommandLineOptions;

Animation2Tilemap.Test/CommandLineOptions/OutputOptionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Animation2Tilemap.CommandLineOptions;
2-
using System.CommandLine;
1+
using System.CommandLine;
2+
using Animation2Tilemap.CommandLineOptions;
33

44
namespace Animation2Tilemap.Test.CommandLineOptions;
55

Animation2Tilemap.Test/Common/NaturalStringComparerTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#pragma warning disable S4144
2-
3-
using Animation2Tilemap.Common;
1+
using Animation2Tilemap.Common;
42

53
namespace Animation2Tilemap.Test.Common;
64

Animation2Tilemap.Test/Services/ConfirmationDialogServiceTests.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ namespace Animation2Tilemap.Test.Services;
55

66
public class ConfirmationDialogServiceTests
77
{
8-
private readonly IConfirmationDialogService _confirmationDialogService;
9-
10-
public ConfirmationDialogServiceTests()
11-
{
12-
_confirmationDialogService = new ConfirmationDialogService();
13-
}
8+
private readonly IConfirmationDialogService _confirmationDialogService = new ConfirmationDialogService();
149

1510
[Theory]
1611
[InlineData("Y", true, true)]

Animation2Tilemap.Test/Services/ImageAlignmentServiceTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Animation2Tilemap.Enums;
2-
using Animation2Tilemap.Services;
1+
using Animation2Tilemap.Services;
32
using Animation2Tilemap.Test.TestHelpers;
43
using Serilog;
54
using SixLabors.ImageSharp;

Animation2Tilemap.Test/Services/ImageHashServiceTests.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ namespace Animation2Tilemap.Test.Services;
77

88
public class ImageHashServiceTests
99
{
10-
private readonly IImageHashService _imageHashService;
11-
12-
public ImageHashServiceTests()
13-
{
14-
_imageHashService = new ImageHashService();
15-
}
10+
private readonly IImageHashService _imageHashService = new ImageHashService();
1611

1712
[Fact]
1813
public void Compute_ShouldReturnSameHash_GivenIdenticalImages()

Animation2Tilemap.Test/Services/TilemapDataServiceTests.cs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,12 @@ namespace Animation2Tilemap.Test.Services;
77

88
public class TilemapDataServiceTests
99
{
10-
private readonly ITilemapDataService _tilemapDataService;
11-
private readonly string _base64WithZlib;
12-
private readonly string _base64WithGzip;
13-
private readonly string _base64;
14-
private readonly string _csvData;
15-
private readonly uint[] _tilemapData;
16-
17-
public TilemapDataServiceTests()
18-
{
19-
_tilemapDataService = new TilemapDataService();
20-
_base64 = TestResourcesHelper.ImportText("Base64.txt");
21-
_base64WithZlib = TestResourcesHelper.ImportText("Base64Zlib.txt");
22-
_base64WithGzip = TestResourcesHelper.ImportText("Base64Gzip.txt");
23-
_csvData = TestResourcesHelper.ImportText("TilemapData.csv");
24-
_tilemapData = TestResourcesHelper.ImportArrayFromJson<uint>("Tilemap.json");
25-
}
10+
private readonly ITilemapDataService _tilemapDataService = new TilemapDataService();
11+
private readonly string _base64WithZlib = TestResourcesHelper.ImportText("Base64Zlib.txt");
12+
private readonly string _base64WithGzip = TestResourcesHelper.ImportText("Base64Gzip.txt");
13+
private readonly string _base64 = TestResourcesHelper.ImportText("Base64.txt");
14+
private readonly string _csvData = TestResourcesHelper.ImportText("TilemapData.csv");
15+
private readonly uint[] _tilemapData = TestResourcesHelper.ImportArrayFromJson<uint>("Tilemap.json");
2616

2717
[Fact]
2818
public void ParseData_ShouldHaveCorrectResult_WithoutCompression()
@@ -55,10 +45,10 @@ public void ParseData_ShouldHaveCorrectResult_WhenUsingGzip()
5545
}
5646

5747
[Fact]
58-
public void ParseData_ShouldHaveCorrectResult_WhenUsingCSV()
48+
public void ParseData_ShouldHaveCorrectResult_WhenUsingCsv()
5949
{
6050
// Act
61-
var tilemapData = _tilemapDataService.ParseData(_csvData, TileLayerFormat.CSV);
51+
var tilemapData = _tilemapDataService.ParseData(_csvData, TileLayerFormat.Csv);
6252

6353
// Assert
6454
Assert.Equal(_tilemapData, tilemapData);
@@ -98,11 +88,11 @@ public void SerializeData_ShouldHaveCorrectResult_WhenUsingGzip()
9888
}
9989

10090
[Fact]
101-
public void SerializeData_ShouldHaveCorrectResult_WhenUsingCSV()
91+
public void SerializeData_ShouldHaveCorrectResult_WhenUsingCsv()
10292
{
10393
// Act
104-
var serialized = _tilemapDataService.SerializeData(_tilemapData, TileLayerFormat.CSV);
105-
var tilemapData = _tilemapDataService.ParseData(serialized, TileLayerFormat.CSV);
94+
var serialized = _tilemapDataService.SerializeData(_tilemapData, TileLayerFormat.Csv);
95+
var tilemapData = _tilemapDataService.ParseData(serialized, TileLayerFormat.Csv);
10696

10797
// Assert
10898
Assert.Equal(_tilemapData, tilemapData);

Animation2Tilemap.Test/Services/XmlSerializerServiceTests.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,19 @@ namespace Animation2Tilemap.Test.Services;
55

66
public class XmlSerializerServiceTests
77
{
8-
private readonly XmlSerializerService _xmlSerializerService;
9-
private readonly Person _person;
8+
private readonly XmlSerializerService _xmlSerializerService = new();
109

11-
public XmlSerializerServiceTests()
10+
private readonly Person _person = new()
1211
{
13-
_xmlSerializerService = new XmlSerializerService();
14-
_person = new Person
12+
Name = "Alice",
13+
Age = 25,
14+
Address = new Address
1515
{
16-
Name = "Alice",
17-
Age = 25,
18-
Address = new Address
19-
{
20-
Street = "Main Street",
21-
City = "New York",
22-
ZipCode = "10001"
23-
}
24-
};
25-
}
16+
Street = "Main Street",
17+
City = "New York",
18+
ZipCode = "10001"
19+
}
20+
};
2621

2722
[Fact]
2823
public void Serialize_ShouldReturnValidXmlString_WhenObjectIsNotNull()

Animation2Tilemap.Test/TestHelpers/TestResourcesHelper.cs

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ namespace Animation2Tilemap.Test.TestHelpers;
55

66
public static class TestResourcesHelper
77
{
8-
public static void ExportArrayToJson<T>(T[] array, string fileName) where T : struct
8+
public static string GetPath(string location)
99
{
1010
var callerClassName = new StackFrame(1).GetMethod()!.DeclaringType!.Name;
11-
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Resources", callerClassName, fileName);
12-
Directory.CreateDirectory(Path.GetDirectoryName(filePath)!);
13-
using var fs = new FileStream(filePath, FileMode.Create);
14-
JsonSerializer.SerializeAsync(fs, array);
11+
var resourceFolder = Path.Combine("Resources", callerClassName);
12+
var path = Path.Combine(resourceFolder, location);
13+
if (File.Exists(path) || Directory.Exists(path))
14+
{
15+
return path;
16+
}
17+
18+
throw new FileNotFoundException($"The file or folder {location} does not exist in the resource folder for {callerClassName}.");
1519
}
1620

1721
public static T[] ImportArrayFromJson<T>(string jsonFile) where T : struct
@@ -23,17 +27,7 @@ public static T[] ImportArrayFromJson<T>(string jsonFile) where T : struct
2327
throw new FileNotFoundException($"The file {filePath} does not exist.");
2428
}
2529
using var fs = new FileStream(filePath, FileMode.Open);
26-
var array = JsonSerializer.DeserializeAsync<T[]>(fs).Result;
27-
return array!;
28-
}
29-
30-
public static void ExportText(string text, string fileName)
31-
{
32-
var callerClassName = new StackFrame(1).GetMethod()!.DeclaringType!.Name;
33-
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Resources", callerClassName, fileName);
34-
Directory.CreateDirectory(Path.GetDirectoryName(filePath)!);
35-
using var sw = new StreamWriter(filePath);
36-
sw.Write(text);
30+
return JsonSerializer.Deserialize<T[]>(fs) ?? Array.Empty<T>();
3731
}
3832

3933
public static string ImportText(string fileName)
@@ -47,17 +41,4 @@ public static string ImportText(string fileName)
4741
using var sr = new StreamReader(filePath);
4842
return sr.ReadToEnd();
4943
}
50-
51-
public static string GetPath(string location)
52-
{
53-
var callerClassName = new StackFrame(1).GetMethod()!.DeclaringType!.Name;
54-
var resourceFolder = Path.Combine("Resources", callerClassName);
55-
var path = Path.Combine(resourceFolder, location);
56-
if (File.Exists(path) || Directory.Exists(path))
57-
{
58-
return path;
59-
}
60-
61-
throw new FileNotFoundException($"The file or folder {location} does not exist in the resource folder for {callerClassName}.");
62-
}
6344
}

Animation2Tilemap/Animation2Tilemap.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
</ItemGroup>
2020

2121
<ItemGroup>
22-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0-preview.3.23174.8" />
23-
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.1-dev-00910" />
24-
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
22+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
23+
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
24+
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
2525
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
2626
</ItemGroup>
2727

0 commit comments

Comments
 (0)