Aetheria/tests/Aetheria.Shared.Tests/AetherDbRootTests.cs
Meta Vens 63d16e81f3 AetherDb for ship authors: rooted at a game folder, found in ModTools; ship-ID rule in create
FindRoot keys on GameData/Aetheria.cc. ShipAuthoringStore.RequireShipId is the one ID rule
(Validate and create), refusing Windows device names and a trailing dot, naming no value.
The add-on's one preference is Game folder; _aetheria_repo, the repo preference and the
dotnet-run invocation are deleted. Smokes take SMOKE_GAME_FOLDER. Not yet built or tested
at this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 06:53:03 +02:00

41 lines
1.6 KiB
C#

using System;
using System.IO;
using Xunit;
[CollectionDefinition("process working directory", DisableParallelization = true)]
public sealed class ProcessWorkingDirectoryCollection { }
// FindRoot reads the process working directory, so these run alone.
[Collection("process working directory")]
public sealed class AetherDbRootTests : IDisposable
{
private readonly TempDirectory _game = new TempDirectory();
private readonly string _previous = Environment.CurrentDirectory;
public void Dispose()
{
Environment.CurrentDirectory = _previous;
_game.Dispose();
}
[Fact]
public void TheRootIsTheNearestFolderWhoseGameDataHoldsAetheriaCc()
{
Directory.CreateDirectory(Path.Combine(_game.Path, "GameData", "Mods", "probe.a"));
File.WriteAllBytes(Path.Combine(_game.Path, "GameData", "Aetheria.cc"), Array.Empty<byte>());
Environment.CurrentDirectory = _game.Path;
var game = Environment.CurrentDirectory;
Environment.CurrentDirectory = Path.Combine(game, "GameData", "Mods", "probe.a");
Assert.Equal(game, AetherDb.FindRoot());
}
[Fact]
public void AFolderHoldingOnlyTheRepositoryMarkerIsNotARoot()
{
Directory.CreateDirectory(Path.Combine(_game.Path, "Aetheria.Shared"));
File.WriteAllText(Path.Combine(_game.Path, "Aetheria.Shared", "Aetheria.Shared.csproj"), "");
Environment.CurrentDirectory = _game.Path;
var error = Assert.Throws<DirectoryNotFoundException>(AetherDb.FindRoot);
Assert.Contains("GameData holds Aetheria.cc", error.Message);
}
}