Economy checks: upkeep walk test gets a control case and a baseline that is actually shared

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-10-27 10:07:40 +01:00
commit dc4838bd9e

View file

@ -393,20 +393,28 @@ public sealed class EconomyChecksTests
[Fact] [Fact]
public void ConsumerDemandFollowsUpkeepIntoAConsumerGoodAndIntoAFillerOfItsRole() public void ConsumerDemandFollowsUpkeepIntoAConsumerGoodAndIntoAFillerOfItsRole()
{ {
using var f = new EconomyFixture(); // Control: coolant is upkeep for a gasket that fills a plain gear role, so it is shared and leads into no consumer good.
f.Good("ore"); using var plain = new EconomyFixture();
f.Good("coolant", inputs: new[] { ("ore", 1) }); plain.Good("ore");
Assert.Equal(new[] { "recipe:commodity:coolant" }, DemandRecords(f)); plain.Good("coolant", inputs: new[] { ("ore", 1) });
plain.Good("gasket", inputs: new[] { ("ore", 1) }, fills: new[] { "Plate" }, upkeep: new[] { ("coolant", 1) });
plain.Hull("tug", HullType.Ship, new[] { ("Plate", 1) });
Assert.Equal(new[] { "recipe:commodity:coolant" }, DemandRecords(plain));
// The refrigerator is a consumer good (a commodity made from roles) that takes coolant as upkeep: coolant leads into it. // The refrigerator is a consumer good (a commodity made from roles) that takes coolant as upkeep: coolant leads into it.
f.Good("fridge", roles: new[] { ("Casing", 1) }, upkeep: new[] { ("coolant", 1) }); using var consumer = new EconomyFixture();
Assert.Empty(DemandRecords(f)); consumer.Good("ore");
consumer.Good("coolant", inputs: new[] { ("ore", 1) });
consumer.Good("fridge", roles: new[] { ("Casing", 1) }, upkeep: new[] { ("coolant", 1) });
Assert.Empty(DemandRecords(consumer));
// Upkeep taken by a filler of a consumer role leads into that role the same way. // Upkeep taken by a filler of a consumer role leads into that role the same way.
f.EditRecipe("commodity:fridge", r => r.Upkeep.Clear()); using var filler = new EconomyFixture();
Assert.Equal(new[] { "recipe:commodity:coolant" }, DemandRecords(f)); filler.Good("ore");
f.Good("gasket", inputs: new[] { ("ore", 1) }, fills: new[] { "Casing" }, upkeep: new[] { ("coolant", 1) }); filler.Good("coolant", inputs: new[] { ("ore", 1) });
Assert.Empty(DemandRecords(f)); filler.Good("gasket", inputs: new[] { ("ore", 1) }, fills: new[] { "Casing" }, upkeep: new[] { ("coolant", 1) });
filler.Good("fridge", roles: new[] { ("Casing", 1) });
Assert.Empty(DemandRecords(filler));
} }
[Fact] [Fact]