From 6463e79317098081dea695554716d370c319cdb7 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 18 Oct 2026 18:47:21 +0200 Subject: [PATCH] Boss fixtures: ordinary hulls only as the copied "like" hull; refusal tests copy a design by its runtime type Co-Authored-By: Claude Sonnet 5.5 --- .../Aetheria.Shared.Tests/LoadoutCommitCommandTests.cs | 10 ++++++---- tests/Aetheria.Shared.Tests/RunGoalTests.cs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/LoadoutCommitCommandTests.cs b/tests/Aetheria.Shared.Tests/LoadoutCommitCommandTests.cs index 45f64e1e0..0c577d80f 100644 --- a/tests/Aetheria.Shared.Tests/LoadoutCommitCommandTests.cs +++ b/tests/Aetheria.Shared.Tests/LoadoutCommitCommandTests.cs @@ -125,19 +125,21 @@ public sealed class LoadoutCommitCommandTests : IDisposable var fit = Fit(); var canary = "Canary9c1e"; var options = CultDocumentMessagePackSerialization.OptionsFor(typeof(HullData).Assembly); - T Copy(T document) => MessagePack.MessagePackSerializer.Deserialize(MessagePack.MessagePackSerializer.Serialize(document, options), options); + object Copy(object document) => MessagePack.MessagePackSerializer.Deserialize(document.GetType(), MessagePack.MessagePackSerializer.Serialize(document.GetType(), document, options), options); using (var cache = Open()) { + // Under a key of its own, so the copy is a second record of the same name, not the first overwritten. + void Add(object document) => Assert.True(cache.Commit(batch => batch.Upsert(document.GetType(), document, new CultRecordKey("duplicate:" + Guid.NewGuid().ToString("N"))))); switch (refusal) { case "ambiguous-hull-product": - cache.Upsert(Copy(cache.GetAll().Single(p => p.Name == fit.hullProduct))); + Add(Copy(cache.GetAll().Single(p => p.Name == fit.hullProduct))); break; case "ambiguous-design": - cache.Upsert(Copy(cache.GetAll().Single(d => d.Name == fit.designName))); + Add(Copy(cache.GetAll().Single(d => d.Name == fit.designName))); break; case "mod-design": - var mod = Copy(cache.GetAll().Single(d => d.Name == fit.designName)); + var mod = (EquippableItemData) Copy(cache.GetAll().Single(d => d.Name == fit.designName)); mod.Name = "Mod gadget"; Assert.True(cache.Commit(batch => batch.Upsert(mod.GetType(), mod, new CultRecordKey("mod-ship:mod.gadget")))); break; diff --git a/tests/Aetheria.Shared.Tests/RunGoalTests.cs b/tests/Aetheria.Shared.Tests/RunGoalTests.cs index d60261a56..5eb9af5d3 100644 --- a/tests/Aetheria.Shared.Tests/RunGoalTests.cs +++ b/tests/Aetheria.Shared.Tests/RunGoalTests.cs @@ -37,7 +37,7 @@ public sealed partial class RunStartTests private HullData[] SoldShipHulls() => _cache.GetAll() .Where(product => product.Manufacturer.IsSet()) .Select(product => _cache.Get(product.Design) as HullData) - .Where(hull => hull != null && hull.HullType == HullType.Ship && hull.Price > 0) + .Where(hull => hull != null && hull.HullType == HullType.Ship && hull.Price > 0 && !hull.Boss) .Distinct().ToArray(); // A Boss hull a faction makes, by the production path: a copy of a sold ship hull (so it builds into a real ship) flagged