acdream/tests/AcDream.App.Tests/Platform/GraphicalLegacyConfigurationMigratorTests.cs
Erik cb6502c8a5 feat(platform): Campaign LA LA0 — extract ApplicationPathSet to AcDream.Platform
The launcher (LA3/LA4) needs the XDG/Windows path contract
(ApplicationPathSet/IApplicationPathEnvironment) without pulling in any
gameplay assembly. Move it out of AcDream.Runtime into a new BCL-only
AcDream.Platform project so the launcher-side Launcher.Core project can
reference it directly per the campaign plan (docs/plans/2026-08-14-launcher-campaign.md,
LA0). Namespace renamed AcDream.Runtime.Platform -> AcDream.Platform;
code is otherwise byte-identical (no logic changes).

AcDream.Runtime now carries a ProjectReference to AcDream.Platform and
re-exports it transitively, so App and Headless keep resolving the type
without a direct reference and K0's Headless single-ProjectReference
guard (HeadlessAssemblyReferencesOnlyTheRuntimeProject) stands unchanged.
The sibling Runtime dependency-boundary guard
(RuntimeProjectDeclaresOnlyApprovedProjectDependencies) does assert
Runtime's own project-reference set, so it needed a deliberate,
documented addition of AcDream.Platform to its expected list.

Moved tests/AcDream.Runtime.Tests/Platform/ApplicationPathSetTests.cs to
a new tests/AcDream.Platform.Tests/ project (namespace
AcDream.Platform.Tests) referencing only AcDream.Platform. Registered
both new projects in AcDream.slnx.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-14 15:19:02 +02:00

66 lines
2 KiB
C#

using AcDream.App.Platform;
using AcDream.Platform;
namespace AcDream.App.Tests.Platform;
public sealed class GraphicalLegacyConfigurationMigratorTests
: IDisposable
{
private readonly string _root = Path.Combine(
Path.GetTempPath(),
"acdream-l0-migration-" + Guid.NewGuid().ToString("N"));
[Fact]
public void MissingCanonicalFilesAreCopiedWithoutOverwriting()
{
string legacy = Path.Combine(_root, "legacy");
string canonical = Path.Combine(_root, "canonical");
Directory.CreateDirectory(legacy);
Directory.CreateDirectory(canonical);
File.WriteAllText(
Path.Combine(legacy, "settings.json"),
"legacy-settings");
File.WriteAllText(
Path.Combine(legacy, "keybinds.json"),
"legacy-keybinds");
File.WriteAllText(
Path.Combine(canonical, "keybinds.json"),
"canonical-keybinds");
var paths = new ApplicationPathSet(
canonical,
Path.Combine(_root, "data"),
Path.Combine(_root, "cache"),
legacy);
IReadOnlyList<string> migrated =
GraphicalLegacyConfigurationMigrator.Migrate(paths);
Assert.Single(migrated);
Assert.Equal(
"legacy-settings",
File.ReadAllText(paths.SettingsFile));
Assert.Equal(
"canonical-keybinds",
File.ReadAllText(paths.KeyBindingsFile));
}
[Fact]
public void NoLegacyDirectoryProducesNoWrites()
{
var paths = new ApplicationPathSet(
Path.Combine(_root, "canonical"),
Path.Combine(_root, "data"),
Path.Combine(_root, "cache"),
LegacyConfigDirectory: null);
Assert.Empty(
GraphicalLegacyConfigurationMigrator.Migrate(paths));
Assert.False(Directory.Exists(paths.ConfigDirectory));
}
public void Dispose()
{
if (Directory.Exists(_root))
Directory.Delete(_root, recursive: true);
}
}