Thing contract, C#: SlotNodeTests pins Slot at key 13

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-27 21:53:50 +01:00
commit ca85200e28

View file

@ -0,0 +1,30 @@
using MessagePack;
namespace GameCult.Thing.Contract.Tests;
/// <summary>
/// thing2:ruling:composition-slot-node: a Slot is union key 13 of Node, one nested slot holding the parameter name, and a
/// composition body places it last in the root's children.
/// </summary>
public sealed class SlotNodeTests
{
[Test]
public void SlotIsArm13WithANestedParamName()
{
Node slot = new SlotNode(new ParamName("body"));
var bytes = MessagePackSerializer.Serialize(typeof(Node), slot, Wire.Options);
Assert.That(bytes, Is.EqualTo(new byte[] { 0x92, 0x0D, 0x91, 0x91, 0xA4, 0x62, 0x6F, 0x64, 0x79 }));
var read = (SlotNode)MessagePackSerializer.Deserialize(typeof(Node), bytes, Wire.Options);
Assert.That(read.Param.Name, Is.EqualTo("body"));
}
[Test]
public void TheCompositionGoldenHoldsTheSlotLastInTheRootsChildren()
{
var composition = (CompositionDocument)Wire.Read(typeof(CompositionDocument), Wire.Golden("composition-all-params.bin"));
var root = (BoxNode)composition.Body;
var slot = (SlotNode)root.Children[^1];
Assert.That(slot.Param.Name, Is.EqualTo("body"));
Assert.That(root.Children, Has.Count.EqualTo(3));
}
}