diff --git a/tests/PKForge.Engine.Tests/HaXAbilityTests.cs b/tests/PKForge.Engine.Tests/HaXAbilityTests.cs index 252a5a3..6042dae 100644 --- a/tests/PKForge.Engine.Tests/HaXAbilityTests.cs +++ b/tests/PKForge.Engine.Tests/HaXAbilityTests.cs @@ -55,19 +55,27 @@ public void OffTableAbilitySurvivesSaveReloadOnGen7() directory = directory.Parent; var savePath = Path.Combine(directory!.FullName, "external", "PKHeX", "Tests", "PKHeX.Core.Tests", "TestData", "SM Project 802.main"); - using (var session = new SaveEngineSession(File.ReadAllBytes(savePath))) + var haxSavePath = Path.Combine(Path.GetTempPath(), "hax-save.main"); + try { - var slot = session.Snapshot.Slots.First(s => s.Box >= 0 && s.Species is not null); - session.ApplyEdit(slot.Box, slot.Slot, new EntityEdit(Ability: Drought)); - Assert.Equal(Drought, session.ReadEntity(slot.Box, slot.Slot).Ability); - File.WriteAllBytes("/tmp/hax-save.main", session.Serialize().ToArray()); - } + using (var session = new SaveEngineSession(File.ReadAllBytes(savePath))) + { + var slot = session.Snapshot.Slots.First(s => s.Box >= 0 && s.Species is not null); + session.ApplyEdit(slot.Box, slot.Slot, new EntityEdit(Ability: Drought)); + Assert.Equal(Drought, session.ReadEntity(slot.Box, slot.Slot).Ability); + File.WriteAllBytes(haxSavePath, session.Serialize().ToArray()); + } - // Reload from disk bytes: the save file itself must carry the edit. - using (var reloaded = new SaveEngineSession(File.ReadAllBytes("/tmp/hax-save.main"))) + // Reload from disk bytes: the save file itself must carry the edit. + using (var reloaded = new SaveEngineSession(File.ReadAllBytes(haxSavePath))) + { + var slot = reloaded.Snapshot.Slots.First(s => s.Box >= 0 && s.Species is not null); + Assert.Equal(Drought, reloaded.ReadEntity(slot.Box, slot.Slot).Ability); + } + } + finally { - var slot = reloaded.Snapshot.Slots.First(s => s.Box >= 0 && s.Species is not null); - Assert.Equal(Drought, reloaded.ReadEntity(slot.Box, slot.Slot).Ability); + File.Delete(haxSavePath); } } } diff --git a/tests/PKForge.Engine.Tests/ShowdownTeamAndBulkTests.cs b/tests/PKForge.Engine.Tests/ShowdownTeamAndBulkTests.cs index fdd80d4..1a8d304 100644 --- a/tests/PKForge.Engine.Tests/ShowdownTeamAndBulkTests.cs +++ b/tests/PKForge.Engine.Tests/ShowdownTeamAndBulkTests.cs @@ -34,7 +34,7 @@ Nonsense line that is not a set field [Fact] public void SplitCutsSetsWhereShowdownDoesAndDropsTeamHeaders() { - var sets = ShowdownTeamService.Split(Team.Replace("\n", "\r\n")); + var sets = ShowdownTeamService.Split(Team.ReplaceLineEndings("\r\n")); Assert.Equal(3, sets.Count); Assert.Equal([(ushort)Species.Pikachu, (ushort)Species.Garchomp, (ushort)Species.Bulbasaur], sets.Select(s => s.Set.Species)); Assert.StartsWith("Pikachu @ Light Ball", sets[0].Text, StringComparison.Ordinal);