From 65a74084cda4d28923e9ef52fa057c12832d6aa1 Mon Sep 17 00:00:00 2001 From: soul Date: Sun, 29 Nov 2026 00:02:13 +0100 Subject: [PATCH] Tests follow the Crew Quarters: installed plant is outside the reach rule, Zenith also buys its crew's goods, and the wants test unequips on a copy (cut habitation-gear) Co-Authored-By: Claude Sonnet 5.5 --- tests/Aetheria.Shared.Tests/HabitationTests.cs | 8 +++++--- tests/Aetheria.Shared.Tests/RunStartTests.cs | 7 ++++--- tests/Aetheria.Shared.Tests/StationWantsTests.cs | 13 +++++++++---- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/HabitationTests.cs b/tests/Aetheria.Shared.Tests/HabitationTests.cs index a3da35ea4..e76ed0179 100644 --- a/tests/Aetheria.Shared.Tests/HabitationTests.cs +++ b/tests/Aetheria.Shared.Tests/HabitationTests.cs @@ -284,8 +284,10 @@ public sealed partial class RunStartTests var eaten = new[] { Good("Water"), Good("Oxygen"), Good("Algae") }; Assert.All(eaten, good => Assert.Contains(good, StationWants.Of(zenith))); - var quarters = zenith.Equipment.Single(IsCrewQuartersUnit); - Assert.NotNull(zenith.TryUnequip(quarters)); - Assert.All(eaten, good => Assert.DoesNotContain(good, StationWants.Of(zenith))); + // Without its quarters (a copy, since a placed station is active). + var copy = (OrbitalEntity) EntitySerializer.Unpack(_items, arena, EntitySerializer.Pack(zenith)); + var quarters = copy.Equipment.Single(IsCrewQuartersUnit); + Assert.NotNull(copy.TryUnequip(quarters)); + Assert.All(eaten, good => Assert.DoesNotContain(good, StationWants.Of(copy))); } } diff --git a/tests/Aetheria.Shared.Tests/RunStartTests.cs b/tests/Aetheria.Shared.Tests/RunStartTests.cs index 4dbb1cbc2..2772d5f7f 100644 --- a/tests/Aetheria.Shared.Tests/RunStartTests.cs +++ b/tests/Aetheria.Shared.Tests/RunStartTests.cs @@ -154,7 +154,8 @@ public sealed partial class RunStartTests : IDisposable private string Maker(FactionProductData product) => product == null ? "nobody" : _cache.Get(product.Manufacturer)?.Name ?? "nobody"; // Every faction's stations, in a main-sector galaxy, carry a heater and a reactor, and nothing, equipped or - // stocked, from a manufacturer that faction cannot reach (LoadoutGenerator.IsAvailable, the one reach rule). + // stocked, from a manufacturer that faction cannot reach (LoadoutGenerator.IsAvailable, the one reach rule). Installed plant, which a + // not-offered product makes (the Crew Quarters, as a facility), is no one's draw and so outside the rule. [Fact] public void EveryFactionsStationsCarryOnlyGearItCanReachIncludingAHeaterAndAReactor() { @@ -169,7 +170,7 @@ public sealed partial class RunStartTests : IDisposable var station = EntitySerializer.Unpack(_items, zone, generator.GenerateStationLoadout(TestStationKinds.TradeHub)); Assert.True(station.Equipment.Count(IsHeater) == 1, $"{faction.Name} station {i}: no heater"); Assert.True(station.Equipment.Any(item => item.Behaviors.OfType().Any()), $"{faction.Name} station {i}: no reactor"); - var unreachable = Made(station).Where(made => made.product == null || !generator.IsAvailable(made.product)).ToList(); + var unreachable = Made(station).Where(made => made.product == null || (LoadoutGenerator.IsOffered(_cache, made.product) && !generator.IsAvailable(made.product))).ToList(); Assert.True(unreachable.Count == 0, $"{faction.Name} station {i} carries {string.Join(", ", unreachable.Select(u => u.item + " by " + Maker(u.product)))}"); } @@ -219,7 +220,7 @@ public sealed partial class RunStartTests : IDisposable { station = EntitySerializer.Unpack(_items, zone, generator.GenerateStationLoadout(TestStationKinds.TradeHub)); Assert.True(station.Equipment.Any(item => item.Behaviors.OfType().Any()), $"station {i}: no reactor"); - var foreign = Made(station).Where(made => made.product == null || !generator.IsAvailable(made.product) || + var foreign = Made(station).Where(made => made.product == null || (LoadoutGenerator.IsOffered(_cache, made.product) && !generator.IsAvailable(made.product)) || made.product.Manufacturer.Key.Equals(_cache.RefOf(zhestokost).Key)).ToList(); Assert.True(foreign.Count == 0, $"station {i} carries {string.Join(", ", foreign.Select(u => u.item + " by " + Maker(u.product)))}"); } diff --git a/tests/Aetheria.Shared.Tests/StationWantsTests.cs b/tests/Aetheria.Shared.Tests/StationWantsTests.cs index a0177faf6..19a4cc52a 100644 --- a/tests/Aetheria.Shared.Tests/StationWantsTests.cs +++ b/tests/Aetheria.Shared.Tests/StationWantsTests.cs @@ -167,25 +167,30 @@ public sealed partial class RunStartTests Assert.Equal(zenith.CargoBays.Count, restored.CargoBays.Count); } - // Zenith buys ore for its haul order: with the order removed, or the silo removed, it buys none. + // Zenith buys ore for its haul order and what its crew quarters eat: with the order removed, or the silo removed, it buys only the crew's goods, and with the quarters gone too, none. [Fact] public void ZenithBuysOnlyTheHaulOrdersGoods() { var zenith = DemoStation("trade-hub"); var order = Assert.Single(_cache.GetAll()); - Assert.Equal(order.Goods.Select(good => good.Key).OrderBy(good => good.Value, StringComparer.Ordinal), StationWants.Of(zenith).OrderBy(good => good.Value, StringComparer.Ordinal)); + var crew = zenith.Equipment.SelectMany(unit => unit.Behaviors.Select(behavior => behavior.Data).OfType()).SelectMany(data => data.Table.Select(row => row.Commodity.Key)).ToArray(); + Assert.NotEmpty(crew); + Assert.Equal(order.Goods.Select(good => good.Key).Concat(crew).OrderBy(good => good.Value, StringComparer.Ordinal), StationWants.Of(zenith).OrderBy(good => good.Value, StringComparer.Ordinal)); Assert.NotEmpty(order.Goods); Assert.All(order.Goods, good => Assert.True(FieldKinds.IsOre(_cache, _cache.Get(good)))); - // The same station without its silo (a copy, since a placed station is active) wants nothing: its goods are its silo's. + // The same station without its silo (a copy, since a placed station is active) wants only what its crew eats: the ore was its silo's. var copy = (OrbitalEntity) EntitySerializer.Unpack(_items, zenith.Zone, EntitySerializer.Pack(zenith)); Assert.Equal(StationWants.Of(zenith).Count, StationWants.Of(copy).Count); + var quarters = copy.Equipment.Single(unit => unit.Behaviors.OfType().Any()); Assert.NotNull(copy.TryUnequip(copy.CargoBays.Single(bay => bay.Data is SiloData))); + Assert.Equal(crew.OrderBy(good => good.Value, StringComparer.Ordinal), StationWants.Of(copy).OrderBy(good => good.Value, StringComparer.Ordinal)); + Assert.NotNull(copy.TryUnequip(quarters)); Assert.Empty(StationWants.Of(copy)); var key = _cache.AllStoredDocuments.Single(stored => stored.Descriptor.DocumentType == typeof(HaulOrderData)).Key; _cache.Commit(batch => batch.Remove(key)); - Assert.Empty(StationWants.Of(zenith)); + Assert.Equal(crew.OrderBy(good => good.Value, StringComparer.Ordinal), StationWants.Of(zenith).OrderBy(good => good.Value, StringComparer.Ordinal)); } // The staged order is a run record: Clear and a discarded Simulation remove it, and a refused stage writes none.