test(battle-node): rewrite TurnEnd dispatch test for two-frame cycle

Replaces the v1.0 single-envelope/OpponentTurn-phase invariant with
the v1.1 two-envelope/AfterReady invariant. Currently failing —
ComputeResponses still does the v1.0 thing. Implementation follows.
This commit is contained in:
gamer147
2026-06-01 14:53:32 -04:00
parent f24fc7c643
commit 96ae090a3a

View File

@@ -99,16 +99,25 @@ public class BattleSessionDispatchTests
}
[Test]
public void TurnEnd_AfterReady_PushesOpponentTurnStart_TransitionsToOpponentTurn()
public void TurnEnd_AfterReady_PushesOpponentTurnStart_ThenTurnEnd_StaysInAfterReady()
{
var s = NewSession();
s.ComputeResponses(NewEnvelope(NetworkBattleUri.InitNetwork));
s.ComputeResponses(NewEnvelope(NetworkBattleUri.InitBattle));
s.ComputeResponses(NewEnvelope(NetworkBattleUri.Loaded));
s.ComputeResponses(NewEnvelope(NetworkBattleUri.Swap));
var responses = s.ComputeResponses(NewEnvelope(NetworkBattleUri.TurnEnd));
Assert.That(responses.Single().Envelope.Uri, Is.EqualTo(NetworkBattleUri.TurnStart));
Assert.That(s.Phase, Is.EqualTo(BattleSessionPhase.OpponentTurn));
// Two-frame cycle: opponent opens its turn, immediately ends it, hands control back.
Assert.That(responses.Select(r => r.Envelope.Uri),
Is.EqualTo(new[] { NetworkBattleUri.TurnStart, NetworkBattleUri.TurnEnd }));
Assert.That(responses.Select(r => r.NoStock),
Is.EqualTo(new[] { false, false }));
// Phase returns to AfterReady within the same call; the next player TurnEnd can fire
// the cycle again. (OpponentTurn is set transiently inside ComputeResponses to document
// intent, but is never externally observable.)
Assert.That(s.Phase, Is.EqualTo(BattleSessionPhase.AfterReady));
}
[Test]