From 8baebcec83ec02cb09d54a6820343702b37c009f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 14 Oct 2026 19:42:39 +0200 Subject: [PATCH] UnionArmGuardTests: ShapeDoc's list arms Circle and Square carry element ids Co-Authored-By: Claude Sonnet 5.5 --- tests/GameCult.Caching.Tests/UnionArmGuardTests.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/GameCult.Caching.Tests/UnionArmGuardTests.cs b/tests/GameCult.Caching.Tests/UnionArmGuardTests.cs index d32bea1d..9879c5a3 100644 --- a/tests/GameCult.Caching.Tests/UnionArmGuardTests.cs +++ b/tests/GameCult.Caching.Tests/UnionArmGuardTests.cs @@ -396,7 +396,11 @@ namespace GameCult.Caching.Tests (shapes ?? List())(ref w); }); - private static Emit CircleArm(int key, int radius) => InnerArm(key, radius); + private static Emit CircleArm(int key, int radius) => (ref MessagePackWriter w) => + { + w.WriteArrayHeader(2); w.Write(key); + w.WriteArrayHeader(2); w.Write(radius); w.Write("0000000000a1"); + }; [TestCase(1)] [TestCase(3)] @@ -429,7 +433,7 @@ namespace GameCult.Caching.Tests [Test] public void KnownArmsOfAnInterfaceUnionByteIdentical() { - var doc = new ShapeDoc { Id = "s1", Shape = new Square { N = 4 }, Shapes = { new Circle { N = 2 }, null! } }; + var doc = new ShapeDoc { Id = "s1", Shape = new Square { N = 4, Id = "0000000000a1" }, Shapes = { new Circle { N = 2, Id = "0000000000a1" }, null! } }; var expected = Shapes(CircleArm(2, 4), List(CircleArm(0, 2), Nil)); Assert.That(Convert.ToHexString(CultDocumentMessagePackSerialization.SerializeUntyped(doc, typeof(ShapeDoc), Registry)), Is.EqualTo(Convert.ToHexString(expected))); Assert.That(Convert.ToHexString(MessagePackSerializer.Serialize(doc, MessagePackSerializerOptions.Standard)), Is.EqualTo(Convert.ToHexString(expected))); @@ -642,8 +646,8 @@ namespace GameCult.Caching.Tests [Union(0, typeof(Circle)), Union(2, typeof(Square))] public interface IShape { } - [MessagePackObject] public class Circle : IShape { [Key(0)] public int N; } - [MessagePackObject] public sealed class Square : IShape { [Key(0)] public int N; } + [MessagePackObject] public class Circle : IShape { [Key(0)] public int N; [Key(1)] [CultElementId] public string Id = string.Empty; } + [MessagePackObject] public sealed class Square : IShape { [Key(0)] public int N; [Key(1)] [CultElementId] public string Id = string.Empty; } [MessagePackObject] public sealed class Triangle : IShape { } [MessagePackObject] public sealed class BigCircle : Circle { }