diff --git a/GFramework.Core.Tests/GFramework.Core.Tests.csproj b/GFramework.Core.Tests/GFramework.Core.Tests.csproj index b71bb9f..b8f7997 100644 --- a/GFramework.Core.Tests/GFramework.Core.Tests.csproj +++ b/GFramework.Core.Tests/GFramework.Core.Tests.csproj @@ -1,7 +1,8 @@  - net8.0;net10.0 + net10.0 + $(TestTargetFrameworks) disable enable false diff --git a/GFramework.Core.Tests/Localization/LocalizationIntegrationTests.cs b/GFramework.Core.Tests/Localization/LocalizationIntegrationTests.cs index 60d95e0..bfcf15e 100644 --- a/GFramework.Core.Tests/Localization/LocalizationIntegrationTests.cs +++ b/GFramework.Core.Tests/Localization/LocalizationIntegrationTests.cs @@ -1,3 +1,4 @@ +using System.IO; using GFramework.Core.Abstractions.Localization; using GFramework.Core.Localization; @@ -9,7 +10,9 @@ public class LocalizationIntegrationTests [SetUp] public void Setup() { - _testDataPath = "/tmp/localization_example"; + _testDataPath = Path.Combine(Path.GetTempPath(), $"gframework_localization_{Guid.NewGuid():N}"); + CreateTestLocalizationFiles(_testDataPath); + var config = new LocalizationConfig { DefaultLanguage = "eng", @@ -23,9 +26,42 @@ public class LocalizationIntegrationTests _manager.Initialize(); } + [TearDown] + public void TearDown() + { + if (Directory.Exists(_testDataPath)) + { + Directory.Delete(_testDataPath, recursive: true); + } + } + private LocalizationManager? _manager; private string _testDataPath = null!; + private static void CreateTestLocalizationFiles(string rootPath) + { + var engPath = Path.Combine(rootPath, "eng"); + var zhsPath = Path.Combine(rootPath, "zhs"); + Directory.CreateDirectory(engPath); + Directory.CreateDirectory(zhsPath); + + File.WriteAllText(Path.Combine(engPath, "common.json"), """ + { + "game.title": "My Game", + "ui.message.welcome": "Welcome, {playerName}!", + "status.health": "Health: {current}/{max}" + } + """); + + File.WriteAllText(Path.Combine(zhsPath, "common.json"), """ + { + "game.title": "我的游戏", + "ui.message.welcome": "欢迎, {playerName}!", + "status.health": "生命值: {current}/{max}" + } + """); + } + [Test] public void GetText_ShouldReturnEnglishText() { diff --git a/GFramework.Ecs.Arch.Tests/GFramework.Ecs.Arch.Tests.csproj b/GFramework.Ecs.Arch.Tests/GFramework.Ecs.Arch.Tests.csproj index 5fac8dd..b4eb273 100644 --- a/GFramework.Ecs.Arch.Tests/GFramework.Ecs.Arch.Tests.csproj +++ b/GFramework.Ecs.Arch.Tests/GFramework.Ecs.Arch.Tests.csproj @@ -1,7 +1,8 @@ - net8.0;net10.0 + net10.0 + $(TestTargetFrameworks) disable enable false diff --git a/GFramework.Game.Tests/GFramework.Game.Tests.csproj b/GFramework.Game.Tests/GFramework.Game.Tests.csproj index 56fa021..f210018 100644 --- a/GFramework.Game.Tests/GFramework.Game.Tests.csproj +++ b/GFramework.Game.Tests/GFramework.Game.Tests.csproj @@ -1,7 +1,8 @@ - net8.0;net10.0 + net10.0 + $(TestTargetFrameworks) disable enable false diff --git a/GFramework.SourceGenerators.Tests/GFramework.SourceGenerators.Tests.csproj b/GFramework.SourceGenerators.Tests/GFramework.SourceGenerators.Tests.csproj index 733f870..48c8406 100644 --- a/GFramework.SourceGenerators.Tests/GFramework.SourceGenerators.Tests.csproj +++ b/GFramework.SourceGenerators.Tests/GFramework.SourceGenerators.Tests.csproj @@ -1,7 +1,8 @@  - net8.0;net10.0 + net10.0 + $(TestTargetFrameworks) disable enable false