Behavior-preserving; 231 BattleNode tests green.
- MinedToken record struct replaces the transpose-prone (int Idx, long CardId,
CardOwner IsSelf) tuple returned by KnownListBuilder.Mine*. Positional deconstruct
keeps the Record*From call sites unchanged.
- enum Stock { Normal, Bypass } replaces the negative `bool noStock` on
IBattleParticipant.PushAsync and DispatchRoute, threaded through both participants,
BattleSession, and all handler construction sites.
- enum KeyActionType mirrors the client's SendKeyActionDataManager.KeyActionType;
the StripKeyActionForOpponent guard compares named values, KeyActionEntry.Type is
the enum (wire-identical via JsonNumberEnumConverter).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using NUnit.Framework;
|
|
using SVSim.BattleNode.Bridge;
|
|
using SVSim.BattleNode.Protocol;
|
|
using SVSim.BattleNode.Protocol.Bodies;
|
|
using SVSim.BattleNode.Sessions;
|
|
using SVSim.BattleNode.Sessions.Participants;
|
|
|
|
namespace SVSim.UnitTests.BattleNode.Sessions.Participants;
|
|
|
|
[TestFixture]
|
|
public class NoOpBotParticipantTests
|
|
{
|
|
[Test]
|
|
public void PushAsync_swallows_without_firing_FrameEmitted()
|
|
{
|
|
var p = new NoOpBotParticipant();
|
|
var fired = 0;
|
|
p.FrameEmitted += (_, _) => { fired++; return Task.CompletedTask; };
|
|
|
|
var env = new MsgEnvelope(
|
|
NetworkBattleUri.TurnEnd, ViewerId: 1, Uuid: "u", Bid: null, Try: 0,
|
|
Cat: EmitCategory.Battle, PubSeq: null, PlaySeq: null,
|
|
Body: new ResultCodeOnlyBody());
|
|
|
|
Assert.DoesNotThrowAsync(() => p.PushAsync(env, Stock.Normal, CancellationToken.None));
|
|
Assert.That(fired, Is.EqualTo(0));
|
|
}
|
|
|
|
[Test]
|
|
public async Task RunAsync_returns_immediately()
|
|
{
|
|
var p = new NoOpBotParticipant();
|
|
await p.RunAsync(CancellationToken.None);
|
|
// If we got here, it returned.
|
|
Assert.Pass();
|
|
}
|
|
|
|
[Test]
|
|
public void ViewerId_is_FakeOpponent()
|
|
{
|
|
var p = new NoOpBotParticipant();
|
|
Assert.That(p.ViewerId, Is.EqualTo(SVSim.BattleNode.Lifecycle.ServerBattleFrames.FakeOpponentViewerId));
|
|
}
|
|
}
|