using System.Reflection; using Xunit; namespace Theriapolis.Tests.Architecture; /// /// 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. /// 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)}"); } /// /// 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). /// [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); } }