Thing contract, C#: SlotNodeTests pins Slot at key 13
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
db3fe05aa0
commit
ca85200e28
1 changed files with 30 additions and 0 deletions
30
tests/GameCult.Thing.Contract.Tests/SlotNodeTests.cs
Normal file
30
tests/GameCult.Thing.Contract.Tests/SlotNodeTests.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue