Hygiene B6b: convert leaky-world tests + HudSystem cosmetics
- 10 EditMode files: every bare trailing world.Dispose() now inside using(world){} (single-world) or a [TearDown]+List<World> (the multi-world reject-matrix tests in BoonApplyTests/RouteSelectSystemTests) — an assertion failure can no longer leak the World and mask the true first failure. No test logic changed.
- HudSystem: collapse the blank-line run before the class close; trim the extracted route-map clause from the READY-panel comment.
466/466 EditMode tests pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ using Unity.Core;
|
||||
using Unity.Entities;
|
||||
using Unity.NetCode;
|
||||
using Unity.Transforms;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ProjectM.Tests
|
||||
{
|
||||
@@ -18,6 +19,14 @@ namespace ProjectM.Tests
|
||||
public class BoonApplyTests
|
||||
{
|
||||
const uint T0 = 3000;
|
||||
readonly List<World> _worlds = new();
|
||||
|
||||
[TearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
foreach (var w in _worlds) if (w.IsCreated) w.Dispose();
|
||||
_worlds.Clear();
|
||||
}
|
||||
|
||||
static (World world, SimulationSystemGroup group, Entity dir, Entity catalog) MakeWorld(byte lifecycle)
|
||||
{
|
||||
@@ -72,6 +81,8 @@ namespace ProjectM.Tests
|
||||
public void ValidPick_AppendsBoonBandRow_AndClearsPending()
|
||||
{
|
||||
var (world, group, dir, catalog) = MakeWorld(RunLifecycle.RoomReward);
|
||||
using (world)
|
||||
{
|
||||
var em = world.EntityManager;
|
||||
var player = MakePicker(em, 1);
|
||||
SendPick(em, 1, index: 1); // Option1 = id 4 (Fleet Foot, MoveSpeed +12%)
|
||||
@@ -85,7 +96,7 @@ namespace ProjectM.Tests
|
||||
Assert.AreEqual(0.12f, mods[0].Value, 1e-4f);
|
||||
Assert.AreEqual(0, em.GetComponentData<BoonOffer>(player).Pending, "pick consumed");
|
||||
Assert.AreEqual(1u, em.GetComponentData<RunRuntime>(dir).BoonPickCounter, "band provenance advanced");
|
||||
world.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -93,28 +104,30 @@ namespace ProjectM.Tests
|
||||
{
|
||||
// Not pending.
|
||||
var (w1, g1, d1, c1) = MakeWorld(RunLifecycle.RoomReward);
|
||||
_worlds.Add(w1);
|
||||
var p1 = MakePicker(w1.EntityManager, 1);
|
||||
w1.EntityManager.SetComponentData(p1, new BoonOffer { Pending = 0, Option0 = 1 });
|
||||
SendPick(w1.EntityManager, 1, 0);
|
||||
g1.Update();
|
||||
Assert.AreEqual(0, BoonRows(w1.EntityManager, p1), "not-pending pick rejected");
|
||||
w1.Dispose();
|
||||
|
||||
// Lifecycle closed (Returning): the straggler pick dies BEFORE any strip could be out-run (D-F4).
|
||||
var (w2, g2, d2, c2) = MakeWorld(RunLifecycle.Returning);
|
||||
_worlds.Add(w2);
|
||||
var p2 = MakePicker(w2.EntityManager, 1);
|
||||
SendPick(w2.EntityManager, 1, 0);
|
||||
g2.Update();
|
||||
Assert.AreEqual(0, BoonRows(w2.EntityManager, p2), "closed-lifecycle pick rejected");
|
||||
using (var q = w2.EntityManager.CreateEntityQuery(typeof(BoonPickRequest)))
|
||||
Assert.AreEqual(0, q.CalculateEntityCount(), "request still consumed");
|
||||
w2.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GraceElapsed_AutoPicksOption0_ForPendingExpeditionPlayers()
|
||||
{
|
||||
var (world, group, dir, catalog) = MakeWorld(RunLifecycle.RoomReward);
|
||||
using (world)
|
||||
{
|
||||
var em = world.EntityManager;
|
||||
var afk = MakePicker(em, 1, o0: 5); // Option0 = id 5 (Iron Constitution, +25 MaxHealth)
|
||||
var run = em.GetComponentData<RunRuntime>(dir);
|
||||
@@ -127,7 +140,7 @@ namespace ProjectM.Tests
|
||||
var mods = em.GetBuffer<StatModifier>(afk);
|
||||
Assert.AreEqual((byte)StatTarget.MaxHealth, mods[0].Target);
|
||||
Assert.AreEqual(0, em.GetComponentData<BoonOffer>(afk).Pending, "gate released");
|
||||
world.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -135,6 +148,8 @@ namespace ProjectM.Tests
|
||||
{
|
||||
// Drive the REAL RunDirectorSystem Returning edge over a player carrying all four bands.
|
||||
var world = new World("BoonStripTest");
|
||||
using (world)
|
||||
{
|
||||
var group = world.GetOrCreateSystemManaged<SimulationSystemGroup>();
|
||||
group.AddSystemToUpdateList(world.GetOrCreateSystem<RunDirectorSystem>());
|
||||
group.SortSystems();
|
||||
@@ -168,7 +183,7 @@ namespace ProjectM.Tests
|
||||
&& after[i].SourceId < Tuning.BoonSourceIdBase + Tuning.BoonSourceIdSpan, "no boon-band survivor");
|
||||
Assert.AreEqual(0, em.GetComponentData<BoonOffer>(player).Pending, "straggler offer zeroed");
|
||||
Assert.AreEqual(RunLifecycle.Staging, em.GetComponentData<RunInfo>(dir).Lifecycle);
|
||||
world.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user