using System.Text.RegularExpressions; namespace AcDream.App.Tests.Physics; public sealed class Issue270ProductionWiringTests { [Fact] public void MovementStats_UseOneEdgeTrackerAndResetItWithTheSession() { // C3c-F1 (2026-08-02): the #270 invariant is unchanged — exactly one // stamina-exhaustion edge tracker, exhaustion dispatched once on the // edge, tracker reset with the session — but the wiring moved from // the factory's deleted ApplyMovementStats body into // LiveMovementStatsApplier, which routes through the Runtime // movement owner's typed seam instead of touching the controller. string applier = ReadSource("Net", "LiveMovementStatsApplier.cs"); string factory = ReadSource("Net", "LiveSessionRuntimeFactory.cs"); Assert.Contains( "_staminaExhaustion.Observe(snapshot.CurrentStamina)", applier, StringComparison.Ordinal); Assert.Single( Regex.Matches( applier, @"_movement\.ReportExhaustion\(\);") .Cast()); Assert.Contains( "_staminaExhaustion.Reset();", applier, StringComparison.Ordinal); Assert.Contains( "_movementStats.Reset();", factory, StringComparison.Ordinal); // The factory keeps zero direct controller mutations: both stat // callbacks route through the applier's seam. Assert.Equal( 2, Regex.Matches(factory, @"_movementStats\.Apply\(").Count); Assert.DoesNotContain( "Motion.ReportExhaustion", factory, StringComparison.Ordinal); } [Fact] public void RemoteSpawnSettle_IsRetriedAndCoversBothCreationRoutes() { string source = ReadSource( "Physics", "LiveEntityNetworkUpdateController.cs"); Assert.Contains( "if (!remote.Body.InContact)", source, StringComparison.Ordinal); Assert.Equal( 3, Regex.Matches(source, @"SeedRemoteSpawnPlacement\(").Count); // C3c-F5: the settle helper moved to Core (SpawnPlacementSettler) so // the local player's Runtime first-entry activation shares the same // tested compressed-first-gravity-frame sweep. Assert.Contains( "SpawnPlacementSettler.TrySettle(", source, StringComparison.Ordinal); } private static string ReadSource(params string[] relativePath) { DirectoryInfo? directory = new(AppContext.BaseDirectory); while (directory is not null) { if (File.Exists(Path.Combine(directory.FullName, "AcDream.slnx"))) { return File.ReadAllText(Path.Combine( directory.FullName, "src", "AcDream.App", Path.Combine(relativePath))); } directory = directory.Parent; } throw new DirectoryNotFoundException("Could not find AcDream.slnx."); } }