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 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-29 00:02:13 +01:00
commit 65a74084cd
3 changed files with 18 additions and 10 deletions

View file

@ -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)));
}
}

View file

@ -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<Reactor>().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<Reactor>().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)))}");
}

View file

@ -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<HaulOrderData>());
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<HabitationData>()).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<Habitation>().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.