Files
SVSimServer/SVSim.BattleEngine.Tests/ConstructionProbeTests.cs
gamer147 2b506574e7 feat(battle-engine-port): M2 step 1 — SingleBattleMgr constructs headless
First green of the M2 go/no-go probe: `new SingleBattleMgr(StandardBattleMgr-
ContentsCreator)` now builds the two-player pair fully headless against the shim,
no Unity runtime. Verdict: headless construction is feasible; every blocker was a
mechanical no-op shim fill or data seam, not a Unity/logic wall.

Shim fills (authored):
- GameMgr: lazy non-null DataMgr/PrefabMgr/InputMgr/SoundMgr/BattleControl.
- GameObject: lazy cached component model so GetComponent<T>/AddComponent<T> return
  non-null no-op instances for Component-derived T (F1: unguarded view touches).
- Resources.Load(string): cached non-null GameObject so the prefab->Instantiate->
  GetComponent chain (UnityEventAgent) yields a real object.
- ClassBattleCardViewBase: re-attach dropped IClassBattleCardView (no-op members);
  ClassBattleCardBase.Setup casts the created view to it.

Engine copy (DP1/DP3 mis-cut fix):
- CardIconControl.cs copied verbatim (manifested) + generated null-stub deleted.
  SplitAndCompleteIconStr is pure string logic on the resolution path that M1 had
  wrongly stubbed as "View" -> null deref in SkillCreator.CreateBuildInfo.

Test harness (SVSim.BattleEngine.Tests, authored fixture):
- HeadlessContentsCreator/HeadlessPhaseCreator: deterministic replica of the solo
  practice init (StandardBattleMgrContentsCreator + SingleBattlePhaseCreator) with
  no-op recovery/replay managers.
- HeadlessCardMaster: reflects the loader cards.json dump into CardMaster.
- HeadlessMasterData: minimal Data.Master (class-character list, empty collections)
  + Data.Load + player/enemy chara ids.
- ConstructionProbeTests.SingleBattleMgr_constructs_headless — GREEN.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 01:36:22 -04:00

43 lines
1.7 KiB
C#

using System;
using NUnit.Framework;
namespace SVSim.BattleEngine.Tests
{
// M2 probe (go/no-go step 1): can BattleManagerBase / the two-player pair be constructed
// HEADLESS at all? This drives the real practice init path
// (`new SingleBattleMgr(StandardBattleMgrContentsCreator)`), which internally builds the
// BattlePlayer + BattleEnemy pair, against the M1 shim — with NO Unity runtime.
//
// The point of this test is diagnostic: if construction throws, the stack trace tells us the
// first shim gap on the *resolution* path (vs the compile path M1 already proved). We assert
// success, but a failure here is the informative outcome we want surfaced.
[TestFixture]
public class ConstructionProbeTests
{
[Test]
public void SingleBattleMgr_constructs_headless()
{
// Mirror the forecast flags the design pins (DP4 / §3): suppress VFX registration and
// collapse wait delays. Set before construction so any ctor-time VFX path no-ops.
HeadlessEngineEnv.EnsureInitialized();
BattleManagerBase.IsForecast = true;
SingleBattleMgr mgr = null;
try
{
mgr = new SingleBattleMgr(new HeadlessContentsCreator());
}
catch (Exception ex)
{
Assert.Fail(
"Headless construction of SingleBattleMgr threw — first shim gap on the " +
"resolution path:\n" + ex);
}
Assert.That(mgr, Is.Not.Null);
Assert.That(mgr.BattlePlayer, Is.Not.Null, "BattlePlayer (self) not created");
Assert.That(mgr.BattleEnemy, Is.Not.Null, "BattleEnemy (opponent) not created");
}
}
}