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

@@ -7,6 +7,11 @@ namespace SVSim.BattleEngine.Tests.SessionEngine
[TestFixture]
public class SessionEngineConstructionTests
{
private TestBattleScope _scope;
[SetUp] public void SetUpScope() { _scope = new TestBattleScope(); }
[TearDown] public void TearDownScope() { _scope?.Dispose(); _scope = null; }
[Test]
public void SessionBattleEngine_instantiates_and_is_not_ready_before_setup()
{
@@ -17,7 +22,6 @@ namespace SVSim.BattleEngine.Tests.SessionEngine
[Test]
public void Setup_builds_two_seat_network_battle_headless()
{
HeadlessEngineEnv.EnsureInitialized();
// Load every card id the two test decks reference so CardMaster can resolve them.
var deckA = Enumerable.Repeat(100011010L, 40).ToList(); // vanilla 1/2 follower x40
var deckB = Enumerable.Repeat(100011010L, 40).ToList();
@@ -48,8 +52,6 @@ namespace SVSim.BattleEngine.Tests.SessionEngine
"draw-misalignment makes a captured play unresolvable against a node-seated deck; the " +
"node-native harness is the post-M-HC-0b oracle. Revive if capture-replay alignment lands.");
HeadlessEngineEnv.EnsureInitialized();
var cl1 = CaptureReplay.Load("battle_test_cl1.ndjson");
var deck = CaptureReplay.SelfDeckFrom(cl1);
// Load ALL deck ids in ONE call: HeadlessCardMaster.Load replaces the static CardMaster each

View File

@@ -9,6 +9,11 @@ namespace SVSim.BattleEngine.Tests.SessionEngine
[TestFixture]
public class SessionEngineShadowReplayTests
{
private TestBattleScope _scope;
[SetUp] public void SetUpScope() { _scope = new TestBattleScope(); }
[TearDown] public void TearDownScope() { _scope?.Dispose(); _scope = null; }
// Frames that are transport/keepalive, not game actions — not ingested.
private static readonly HashSet<string> SkipUris = new()
{
@@ -35,8 +40,6 @@ namespace SVSim.BattleEngine.Tests.SessionEngine
"against a node-seated deck hits the documented draw-misalignment artifact once the " +
"receive path actually resolves. Revive if a capture-replay alignment path lands.");
HeadlessEngineEnv.EnsureInitialized();
var cl1 = CaptureReplay.Load("battle_test_cl1.ndjson");
var cl2 = CaptureReplay.Load("battle_test_cl2.ndjson");
var deckA = CaptureReplay.SelfDeckFrom(cl1);

View File

@@ -8,6 +8,11 @@ namespace SVSim.BattleEngine.Tests.SessionEngine;
[TestFixture]
public class SessionEngineSpellboostTests
{
private TestBattleScope _scope;
[SetUp] public void SetUpScope() { _scope = new TestBattleScope(); }
[TearDown] public void TearDownScope() { _scope?.Dispose(); _scope = null; }
[Test]
public void EngineGlobalInit_makes_a_fresh_engine_ready()
{