CatalogMemberVectorTests: member types top-level in the test namespace

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-27 22:23:13 +01:00
commit 06595a2d11

View file

@ -10,6 +10,53 @@ using NUnit.Framework;
namespace GameCult.Caching.Tests
{
[MessagePackObject]
public sealed class CatalogMemberMark
{
[Key(0)] public string Label = string.Empty;
[Key(1)] public int Weight;
}
[Union(0, typeof(CatalogMemberTextArm))]
[Union(1, typeof(CatalogMemberCountArm))]
public abstract class CatalogMemberArm { }
[MessagePackObject]
public sealed class CatalogMemberTextArm : CatalogMemberArm
{
[Key(0)] public string Text = string.Empty;
}
[MessagePackObject]
public sealed class CatalogMemberCountArm : CatalogMemberArm
{
[Key(0)] public int Count;
}
[CultDocument("tests.catalog_members", "tests.catalog_members.v1")]
[MessagePackObject]
public sealed class CatalogMembersDocument
{
[Key(0)] [CultName] public string Title = string.Empty;
[Key(1)] [CultIndex("sku")] public string Sku = string.Empty;
[Key(2)] public int Count;
[Key(3)] public ulong Total;
[Key(4)] public double Ratio;
[Key(5)] public float Scale;
[Key(6)] public bool Flag;
[Key(7)] public int? MaybeCount;
[Key(8)] public string? Note;
[Key(9)] public List<string> Tags = new();
[Key(10)] public string[] Labels = Array.Empty<string>();
[Key(11)] public byte[] Raw = Array.Empty<byte>();
[Key(12)] public List<byte[]> Chunks = new();
[Key(13)] public Dictionary<string, int> Weights = new();
[Key(14)] public CatalogMemberMark Mark = new();
[Key(15)] public CatalogMemberArm? Arm;
// Slot 16 is a gap.
[Key(17)] public long Late;
}
// tests/vectors/catalog-members (variants:ruling:rs-catalog-member-rows-every-member): a record holding a value in every
// member shape, in two stores. csharp-members-store.cc is written by this reference, under CULTCACHE_WRITE_VECTORS=1, and
// carries one catalog row per member; every other run compares its bytes. rust-members-empty-store.cc is written by
@ -18,53 +65,6 @@ namespace GameCult.Caching.Tests
{
private const string Vector = "catalog-members";
[MessagePackObject]
public sealed class CatalogMemberMark
{
[Key(0)] public string Label = string.Empty;
[Key(1)] public int Weight;
}
[Union(0, typeof(CatalogMemberTextArm))]
[Union(1, typeof(CatalogMemberCountArm))]
public abstract class CatalogMemberArm { }
[MessagePackObject]
public sealed class CatalogMemberTextArm : CatalogMemberArm
{
[Key(0)] public string Text = string.Empty;
}
[MessagePackObject]
public sealed class CatalogMemberCountArm : CatalogMemberArm
{
[Key(0)] public int Count;
}
[CultDocument("tests.catalog_members", "tests.catalog_members.v1")]
[MessagePackObject]
public sealed class CatalogMembersDocument
{
[Key(0)] [CultName] public string Title = string.Empty;
[Key(1)] [CultIndex("sku")] public string Sku = string.Empty;
[Key(2)] public int Count;
[Key(3)] public ulong Total;
[Key(4)] public double Ratio;
[Key(5)] public float Scale;
[Key(6)] public bool Flag;
[Key(7)] public int? MaybeCount;
[Key(8)] public string? Note;
[Key(9)] public List<string> Tags = new();
[Key(10)] public string[] Labels = Array.Empty<string>();
[Key(11)] public byte[] Raw = Array.Empty<byte>();
[Key(12)] public List<byte[]> Chunks = new();
[Key(13)] public Dictionary<string, int> Weights = new();
[Key(14)] public CatalogMemberMark Mark = new();
[Key(15)] public CatalogMemberArm? Arm;
// Slot 16 is a gap.
[Key(17)] public long Late;
}
private static readonly CultDocumentRegistry Registry = CultDocumentRegistry.ForTypes(new[] { typeof(CatalogMembersDocument) });
private static CatalogMembersDocument Expected() => new()