From 8cb53049aa81c2ba724bec4c44754ff455dc61f9 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 8 Oct 2026 18:53:18 +0200 Subject: [PATCH] PiratesFactionCommandTests: strip the copy through a shipped-assembly registry, then seed the test global AetherDb.Open demands Co-Authored-By: Claude Sonnet 5.5 --- .../PiratesFactionCommandTests.cs | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/PiratesFactionCommandTests.cs b/tests/Aetheria.Shared.Tests/PiratesFactionCommandTests.cs index f5b0d5851..feed84228 100644 --- a/tests/Aetheria.Shared.Tests/PiratesFactionCommandTests.cs +++ b/tests/Aetheria.Shared.Tests/PiratesFactionCommandTests.cs @@ -5,6 +5,9 @@ using System; using System.IO; using System.Linq; +using System.Reflection; +using GameCult.Caching; +using GameCult.Caching.MessagePack; using Xunit; // AetherDb's pirates-faction command (aetheria-release, cut pirates-record), run on a scratch copy of the shipped catalog @@ -18,13 +21,28 @@ public sealed class PiratesFactionCommandTests : IDisposable { Directory.CreateDirectory(Path.Combine(_root, "GameData")); File.Copy(Path.Combine(AetherDb.FindRoot(), "GameData", "Aetheria.cc"), CatalogPath); - var db = AetherDb.Open(catalogWritable: true, root: _root); - var pirates = db.Cache.GetAll().Single(faction => faction.Name == "Pirates"); - var ours = db.Cache.RefOf(pirates); - foreach (var product in db.Cache.GetAll().Where(product => product.Manufacturer.Equals(ours)).ToArray()) - Assert.True(db.Cache.Remove(db.Cache.RefOf(product).Key)); - Assert.True(db.Cache.Remove(ours.Key)); - db.Cache.Dispose(); + // AetherDb.Open composes the process-wide registry, which in this test host also sees this assembly's TestCatalogGlobal + // (see FireControlCut7Tests). So the copy is stripped through a registry scoped to the shipped assembly and then given + // the record that registry's shared sibling demands, as AetheriaStoresTests does. + var registry = CultDocumentRegistry.ForTypes(typeof(ItemData).Assembly.GetTypes() + .Where(t => t is { IsAbstract: false, IsInterface: false }) + .Where(t => t.GetCustomAttribute() != null)); + using (var cache = new CultCache(registry)) + { + cache.AddBackingStore(new SingleFileMessagePackBackingStore(CatalogPath), AetheriaStores.CatalogTypes); + var pirates = cache.GetAll().Single(faction => faction.Name == "Pirates"); + var ours = cache.RefOf(pirates); + foreach (var product in cache.GetAll().Where(product => product.Manufacturer.Equals(ours)).ToArray()) + Assert.True(cache.Remove(cache.RefOf(product).Key)); + Assert.True(cache.Remove(ours.Key)); + cache.FlushAsync().Wait(); + } + using (var cache = new CultCache()) + { + cache.AddBackingStore(new SingleFileMessagePackBackingStore(CatalogPath), AetheriaStores.CatalogTypes); + cache.Upsert(new TestCatalogGlobal { Name = "Temperament" }); + cache.FlushAsync().Wait(); + } } public void Dispose() => Directory.Delete(_root, true);