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)); + } +}