feat(battle-node): KnownListBuilder pure transforms (knownList synth, target rename)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
79
SVSim.UnitTests/BattleNode/Sessions/KnownListBuilderTests.cs
Normal file
79
SVSim.UnitTests/BattleNode/Sessions/KnownListBuilderTests.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using NUnit.Framework;
|
||||
using SVSim.BattleNode.Sessions.Dispatch;
|
||||
|
||||
namespace SVSim.UnitTests.BattleNode.Sessions;
|
||||
|
||||
[TestFixture]
|
||||
public class KnownListBuilderTests
|
||||
{
|
||||
// orderList as it arrives in a RawBody: a list of single-key op dicts.
|
||||
private static List<object?> OrderListMove(int idx, int from, int to) => new()
|
||||
{
|
||||
new Dictionary<string, object?>
|
||||
{
|
||||
["move"] = new Dictionary<string, object?>
|
||||
{
|
||||
["idx"] = new List<object?> { (long)idx },
|
||||
["isSelf"] = 1L, ["from"] = (long)from, ["to"] = (long)to,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void ExtractMoveTo_returns_to_for_matching_idx()
|
||||
{
|
||||
var to = KnownListBuilder.ExtractMoveTo(OrderListMove(3, 10, 20), playIdx: 3);
|
||||
Assert.That(to, Is.EqualTo(20));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtractMoveTo_returns_null_when_no_move_op_matches()
|
||||
{
|
||||
Assert.That(KnownListBuilder.ExtractMoveTo(OrderListMove(3, 10, 20), playIdx: 99), Is.Null);
|
||||
Assert.That(KnownListBuilder.ExtractMoveTo(null, playIdx: 3), Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildPlayedCard_synthesizes_entry_for_deck_card()
|
||||
{
|
||||
var deckMap = new Dictionary<int, long> { [3] = 128821011L };
|
||||
var entry = KnownListBuilder.BuildPlayedCard(deckMap, playIdx: 3, orderList: OrderListMove(3, 10, 20));
|
||||
|
||||
Assert.That(entry, Is.Not.Null);
|
||||
Assert.That(entry!.Idx, Is.EqualTo(3));
|
||||
Assert.That(entry.CardId, Is.EqualTo(128821011L));
|
||||
Assert.That(entry.To, Is.EqualTo(20));
|
||||
Assert.That(entry.Spellboost, Is.EqualTo(0));
|
||||
Assert.That(entry.AttachTarget, Is.EqualTo(""));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildPlayedCard_returns_null_for_token_idx_not_in_deck()
|
||||
{
|
||||
var deckMap = new Dictionary<int, long> { [3] = 128821011L };
|
||||
var entry = KnownListBuilder.BuildPlayedCard(deckMap, playIdx: 31, orderList: OrderListMove(31, 10, 20));
|
||||
Assert.That(entry, Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RenameTargets_passes_isSelf_through_verbatim()
|
||||
{
|
||||
var targetList = new List<object?>
|
||||
{
|
||||
new Dictionary<string, object?> { ["targetIdx"] = 8L, ["isSelf"] = 0L },
|
||||
};
|
||||
var renamed = KnownListBuilder.RenameTargets(targetList);
|
||||
|
||||
Assert.That(renamed, Is.Not.Null);
|
||||
Assert.That(renamed!.Count, Is.EqualTo(1));
|
||||
Assert.That(renamed[0].TargetIdx, Is.EqualTo(8));
|
||||
Assert.That(renamed[0].IsSelf, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RenameTargets_returns_null_for_missing_or_empty()
|
||||
{
|
||||
Assert.That(KnownListBuilder.RenameTargets(null), Is.Null);
|
||||
Assert.That(KnownListBuilder.RenameTargets(new List<object?>()), Is.Null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user