57fe6bf173
Proves Theriapolis.Core works untouched under Godot's csproj — the worldgen
pipeline produces byte-identical output whether invoked from the Tools CLI
or from inside the Godot process. This is the determinism contract surviving
the port.
Architecture test:
CoreNoDependencyTests now forbids Godot.* and GodotSharp in addition to
Microsoft.Xna and MonoGame. Both bans stay in force for the duration of
the port so neither engine can leak into Core.
Determinism oracle:
New worldgen-hash Tools command runs the full pipeline and prints FNV-1a
hashes for every channel (elevation, moisture, temperature, biomes,
settlements, polylines) plus per-stage hashes. Pairs with the Godot
smoke-test for cross-process verification.
Godot-side smoke test:
SmokeTest.cs runs WorldGenerator.RunAll inside the Godot process; Main.cs
fires it on --smoke-test <seed>. Resolves Content/Data via res:// walk-up.
M0 hello-world behaviour preserved when launched without the flag.
Verification (seed 12345):
- dotnet run -- worldgen-hash and Godot --headless --smoke-test agree on
all 6 channels and all 14 per-stage hashes (diff produces zero output)
- 10-run sweeps stable on both sides post-determinism-fix
- dotnet test: 708/708 pass
Closes M1 of theriapolis-rpg-implementation-plan-godot-port.md.
Next: M2 (world map render).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
using System.Reflection;
|
|
using Xunit;
|
|
|
|
namespace Theriapolis.Tests.Architecture;
|
|
|
|
/// <summary>
|
|
/// Hard rule #1: Theriapolis.Core must not reference any rendering engine.
|
|
/// This test reflects over Core.dll and fails the build if any forbidden assembly
|
|
/// is referenced. Both MonoGame/XNA (legacy) and Godot (M1+ port) are banned —
|
|
/// keep both bans for the duration of the port so the in-flight branch can't
|
|
/// regress either way.
|
|
/// </summary>
|
|
public sealed class CoreNoDependencyTests
|
|
{
|
|
private static readonly string[] ForbiddenPrefixes =
|
|
{
|
|
"Microsoft.Xna",
|
|
"MonoGame",
|
|
"Godot",
|
|
"GodotSharp",
|
|
};
|
|
|
|
[Fact]
|
|
public void Core_DoesNotReference_RenderingEngines()
|
|
{
|
|
var coreAssembly = typeof(Theriapolis.Core.C).Assembly;
|
|
var referenced = coreAssembly.GetReferencedAssemblies();
|
|
|
|
var violations = referenced
|
|
.Where(r => ForbiddenPrefixes.Any(p => r.Name?.StartsWith(p, StringComparison.OrdinalIgnoreCase) == true))
|
|
.Select(r => r.Name!)
|
|
.ToList();
|
|
|
|
Assert.True(violations.Count == 0,
|
|
$"Theriapolis.Core must not reference any rendering engine (MonoGame/XNA/Godot). " +
|
|
$"Violations: {string.Join(", ", violations)}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Phase 4 also requires the new Core namespaces (Tactical, Entities,
|
|
/// Persistence, Time) to be MonoGame-free. The reflection check above
|
|
/// already proves this at the assembly level — this test is a belt-and-
|
|
/// braces audit that the namespaces actually exist (i.e., we didn't
|
|
/// accidentally put them in Game).
|
|
/// </summary>
|
|
[Theory]
|
|
[InlineData("Theriapolis.Core.Tactical")]
|
|
[InlineData("Theriapolis.Core.Entities")]
|
|
[InlineData("Theriapolis.Core.Persistence")]
|
|
[InlineData("Theriapolis.Core.Time")]
|
|
public void CoreNamespace_ExistsAndIsMonoGameFree(string ns)
|
|
{
|
|
var asm = typeof(Theriapolis.Core.C).Assembly;
|
|
var anyType = asm.GetTypes().FirstOrDefault(t => t.Namespace == ns);
|
|
Assert.NotNull(anyType);
|
|
}
|
|
}
|