using NUnit.Framework; using Unity.Entities; using ProjectM.Simulation; namespace ProjectM.Tests { /// /// Setup smoke test: proves the DOTS toolchain compiles, source-generates, and ticks. /// Boots a bare ECS world, registers in the /// SimulationSystemGroup, and asserts the component advances once per group update. /// (Netcode client/server world boot is covered separately by the ยง3 Play Mode check.) /// public class HeartbeatSystemTests { [Test] public void Heartbeat_Advances_Once_Per_SimulationGroup_Tick() { using var world = new World("HeartbeatTestWorld"); var simulationGroup = world.GetOrCreateSystemManaged(); var heartbeatSystem = world.GetOrCreateSystem(); simulationGroup.AddSystemToUpdateList(heartbeatSystem); simulationGroup.SortSystems(); var entityManager = world.EntityManager; var entity = entityManager.CreateEntity(typeof(Heartbeat)); Assert.AreEqual(0, entityManager.GetComponentData(entity).Tick, "Heartbeat should start at 0."); const int ticks = 8; for (int i = 0; i < ticks; i++) { simulationGroup.Update(); } Assert.AreEqual(ticks, entityManager.GetComponentData(entity).Tick, "Heartbeat.Tick should advance exactly once per SimulationSystemGroup update."); } } }