From bc3ce8fc26703d1f6bd84db2f4a99c558cbebf43 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 14 Sep 2026 22:35:16 +0200 Subject: [PATCH] Pin loadout product order against the live cache's enumeration order (Cut 10 fix) The key-order test wrote its products and then reopened the store, whose snapshot already returned them in key order, so removing the explicit OrderBy still passed. The products are now committed into the open cache in z-then-a order, the test asserts that enumeration order first, and Materialize must still pick lamp-a. Co-Authored-By: Claude Opus 5 --- tests/Aetheria.Shared.Tests/LoadoutTests.cs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/LoadoutTests.cs b/tests/Aetheria.Shared.Tests/LoadoutTests.cs index 71fcc8d30..cbceb900c 100644 --- a/tests/Aetheria.Shared.Tests/LoadoutTests.cs +++ b/tests/Aetheria.Shared.Tests/LoadoutTests.cs @@ -185,22 +185,18 @@ public sealed class LoadoutTests : IDisposable Assert.Equal(1000 - 115, credits); } - // Two more Lamp products, written so insertion order (z before a) disagrees with record-key order. + // Two more Lamp products, upserted into the live cache so its enumeration order (z before a) disagrees with + // record-key order; a reopened snapshot could already hand them back sorted. [Fact] public void FirstAvailableProductInKeyOrderBuildsTheSlot() { - using (var catalog = AetheriaStores.Open(Catalog, catalogWritable: true)) - { - var maker = catalog.RefOf(catalog.GetByName("Maker")); - var lamp = new CultRecordRef(catalog.RefOf(catalog.GetByName("Lamp")).Key); - catalog.Commit(batch => - { - foreach (var key in new[] { "lamp-z", "lamp-a" }) - batch.Upsert(typeof(FactionProductData), new FactionProductData { Name = key, Design = lamp, Manufacturer = maker }, new CultRecordKey(key)); - }); - } + using var cache = AetheriaStores.Open(Catalog, catalogWritable: true); + var maker = cache.RefOf(cache.GetByName("Maker")); + var lamp = new CultRecordRef(cache.RefOf(cache.GetByName("Lamp")).Key); + foreach (var key in new[] { "lamp-z", "lamp-a" }) + cache.Commit(batch => batch.Upsert(typeof(FactionProductData), new FactionProductData { Name = key, Design = lamp, Manufacturer = maker }, new CultRecordKey(key))); + Assert.Equal(new[] { "lamp-z", "lamp-a" }, cache.GetAll().Select(p => p.Name).Where(name => name.StartsWith("lamp-"))); - using var cache = Open(); var items = new ItemManager(cache, RunSaveTests.TestSettings(), _ => { }); var hand = HandBuilt(cache); string LampProduct(Predicate available, List failures)