Economy tests: pin the survivors of the diff (null RoleInputs keeps the rest, key-ordered recipe-less designs, unoffered recipe designs name roles, mixed takes line)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-10-27 11:30:14 +01:00
commit 1efd8343da
3 changed files with 29 additions and 0 deletions

View file

@ -259,6 +259,10 @@ public sealed class EconomyCommandTests
var withRole = new StringWriter();
EconomyCommand.Report(f.Cache, withRole);
Assert.Contains("commodity:steel <- 2 x OreRole | Mill", withRole.ToString());
f.EditRecipe("commodity:steel", r => r.Inputs.Add(new CommodityCount { Commodity = EconomyFixture.Item("commodity:ore"), Count = 1 }));
var both = new StringWriter();
EconomyCommand.Report(f.Cache, both);
Assert.Contains("commodity:steel <- 1 x commodity:ore, 2 x OreRole | Mill", both.ToString());
Assert.Contains("gear:laser <- 2 x Plate | Mill", withRole.ToString());
Assert.True(text.IndexOf("commodity:ore <-", StringComparison.Ordinal) < text.IndexOf("commodity:plate <-", StringComparison.Ordinal));
Assert.True(text.IndexOf("commodity:plate <-", StringComparison.Ordinal) < text.IndexOf("gear:laser <-", StringComparison.Ordinal));

View file

@ -45,6 +45,14 @@ public sealed class EconomyNullGuardTests
Assert.NotEmpty(EconomyChecks.Deep(f.Cache));
}
[Fact]
public void ANullRoleInputsReadsAsTheListWithoutItAndKeepsTheRestOfTheRecipe()
{
using var f = EconomyFixture.Healthy();
f.EditRecipe("commodity:plate", r => r.RoleInputs = null);
Assert.Empty(EconomyChecks.Check(f.Cache).Faults.Where(x => x.Invariant != EconomyChecks.LRecipe));
}
[Fact]
public void ANullEntryInAListIsAnLRecipeFault()
{

View file

@ -134,6 +134,23 @@ public sealed class RecipeRoleInputTests
return f;
}
[Fact]
public void ADesignWithARecipeNamesItsRolesOfferedOrNot()
{
using var f = Casings(g => g.Gear("shell", new[] { ("Casing", 1) }, offered: false));
Assert.DoesNotContain(EconomyChecks.SourceSink(f.Cache), x => x.Record == "recipe:" + EconomyFixture.Key("cap") && x.Message.Contains("no sink"));
Assert.Equal(new[] { "recipe:" + EconomyFixture.Key("alloy") }, Records(EconomyChecks.ConsumerDemand(f.Cache), EconomyChecks.LDemand));
}
[Fact]
public void OfferedDesignsWithoutARecipeAreFaultedInKeyOrder()
{
using var f = EconomyFixture.Healthy();
f.Gear("zeta", new[] { ("Plate", 1) }, recipe: false);
f.Gear("alpha", new[] { ("Plate", 1) }, recipe: false);
Assert.Equal(new[] { "gear:alpha", "gear:zeta" }, EconomyChecks.Recipe(f.Cache).Select(x => x.Record));
}
[Fact]
public void AnOfferedDesignWithoutARecipeStillNamesItsRoles()
{