From ca85200e28e81cd9c15f585378cce6208a148467 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 27 Nov 2026 21:53:50 +0100 Subject: [PATCH] Thing contract, C#: SlotNodeTests pins Slot at key 13 Co-Authored-By: Claude Sonnet 5.5 --- .../SlotNodeTests.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/GameCult.Thing.Contract.Tests/SlotNodeTests.cs diff --git a/tests/GameCult.Thing.Contract.Tests/SlotNodeTests.cs b/tests/GameCult.Thing.Contract.Tests/SlotNodeTests.cs new file mode 100644 index 0000000..2de2537 --- /dev/null +++ b/tests/GameCult.Thing.Contract.Tests/SlotNodeTests.cs @@ -0,0 +1,30 @@ +using MessagePack; + +namespace GameCult.Thing.Contract.Tests; + +/// +/// 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. +/// +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)); + } +}