test(engine-ambient): TestBattleScope + HeadlessFixture split for multi-instance

Step 6 of multi-instancing migration. HeadlessEngineEnv.EnsureInitialized
is split into EnsureProcessGlobals (idempotent, process-once) +
SeedCharaIdsOnCurrentAmbient (per-test). New TestBattleScope IDisposable
sets up a fresh BattleAmbientContext per test. NonParallelizable removed
from converted classes; assembly-level Parallelizable(Fixtures) enabled.

SVSim.BattleEngine.Tests fully green under parallel test execution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-07 22:24:21 -04:00
parent 1ba75c565a
commit 8af1be6555
22 changed files with 238 additions and 39 deletions

View File

@@ -39,6 +39,11 @@ namespace SVSim.BattleEngine.Tests
// FALSE branch, exactly as M4's load-bearing probe did when it removed its seed.
private const int GateFalseSeed = 0;
private TestBattleScope _scope;
[SetUp] public void SetUpScope() { _scope = new TestBattleScope(); }
[TearDown] public void TearDownScope() { _scope?.Dispose(); _scope = null; }
private static void SetPrivateField(object obj, string name, object value)
{
var t = obj.GetType();
@@ -53,12 +58,13 @@ namespace SVSim.BattleEngine.Tests
// play_count is per-mgr state and a resolved play mutates the board, so the two branches must
// not share a battle. Mirrors the M4 BuffFollowerOracleTests setup verbatim, parameterized on
// the seed (which is the only thing M11 varies between branches).
private static (BattleCardBase card, CardParameter param, int ppBefore, int ppAfter,
private (BattleCardBase card, CardParameter param, int ppBefore, int ppAfter,
int handBefore, bool inHandAfter, int inplayBefore, bool onBoardAfter, int inplayAfter)
PlayGatedSelfBuff(int seededPlayCount)
{
BattleManagerBase.IsForecast = true; // suppress VFX registration (F1)
var mgr = new SingleBattleMgr(new HeadlessContentsCreator());
_scope.Ctx.Mgr = mgr; // route GetIns() to this branch's mgr
mgr.IsRecovery = true; // collapse wait delays to 0 (F1)
var player = mgr.BattlePlayer;
@@ -106,8 +112,6 @@ namespace SVSim.BattleEngine.Tests
[Test]
public void Gated_fanfare_fires_when_seeded_true_and_is_suppressed_when_false()
{
HeadlessEngineEnv.EnsureInitialized();
// ----- Branch 1: gate TRUE (play_count 5 > 2) -> the fanfare FIRES (M4 dimension). -----
var t = PlayGatedSelfBuff(GateTrueSeed);