Aetheria/tests/Aetheria.Shared.Tests/AetherDbRootTests.cs
Meta Vens 0b5cad8903 ship_cc: layout_revision and valid_ship_id as pure functions, fixed-text errors; pins and tests for the authoring-tool Low findings
layout_revision(shape, hardpoints) is the revision rule replace_layout and Package share.
SHIP_ID_CHARS and RESERVED_SHIP_IDS mirror ShipAuthoringStore.RequireShipId; ShipSchemaPinTests
sweeps every character and every candidate stem against the C# rule. ship_cc errors no longer
carry the path, mount id, anchor id or object name. C# tests: create judges the ID not the
display name, FindRoot answers the working directory itself, short trailing-dot IDs.

Builds: yes (C# test edits and Python only).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 09:49:39 +02:00

50 lines
2 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 TheRootIsTheWorkingDirectoryItselfWhenItsGameDataHoldsAetheriaCc()
{
Directory.CreateDirectory(Path.Combine(_game.Path, "GameData"));
File.WriteAllBytes(Path.Combine(_game.Path, "GameData", "Aetheria.cc"), Array.Empty<byte>());
Environment.CurrentDirectory = _game.Path;
Assert.Equal(Environment.CurrentDirectory, 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);
}
}