b451f83174
Captures the pre-Godot-port state of the codebase. This is the rollback anchor for the Godot port (M0 of theriapolis-rpg-implementation-plan-godot-port.md). All Phase 0 through Phase 6.5 work is included; Phase 7 is in flight. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
namespace Theriapolis.Tests;
|
|
|
|
/// <summary>Shared test utilities.</summary>
|
|
internal static class TestHelpers
|
|
{
|
|
/// <summary>
|
|
/// Resolves the Content/Data directory for tests.
|
|
/// xUnit runs from the test output directory; the .csproj copies Data/* there.
|
|
/// </summary>
|
|
public static string DataDirectory
|
|
{
|
|
get
|
|
{
|
|
// First: "Data" next to the test assembly (copied by .csproj)
|
|
string local = Path.Combine(AppContext.BaseDirectory, "Data");
|
|
if (Directory.Exists(local)) return local;
|
|
|
|
// Fallback: walk up from the assembly to find Content/Data
|
|
string? dir = AppContext.BaseDirectory;
|
|
for (int i = 0; i < 7; i++)
|
|
{
|
|
string candidate = Path.Combine(dir ?? "", "Content", "Data");
|
|
if (Directory.Exists(candidate)) return candidate;
|
|
dir = Path.GetDirectoryName(dir);
|
|
}
|
|
|
|
throw new DirectoryNotFoundException(
|
|
"Cannot locate Content/Data directory. " +
|
|
$"Searched from: {AppContext.BaseDirectory}");
|
|
}
|
|
}
|
|
}
|