diff --git a/tests/Aetheria.Shared.Tests/EconomyCommandTests.cs b/tests/Aetheria.Shared.Tests/EconomyCommandTests.cs index 74776b9db..c0c04f89c 100644 --- a/tests/Aetheria.Shared.Tests/EconomyCommandTests.cs +++ b/tests/Aetheria.Shared.Tests/EconomyCommandTests.cs @@ -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)); diff --git a/tests/Aetheria.Shared.Tests/EconomyNullGuardTests.cs b/tests/Aetheria.Shared.Tests/EconomyNullGuardTests.cs index b1b633070..dd8e51f31 100644 --- a/tests/Aetheria.Shared.Tests/EconomyNullGuardTests.cs +++ b/tests/Aetheria.Shared.Tests/EconomyNullGuardTests.cs @@ -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() { diff --git a/tests/Aetheria.Shared.Tests/RecipeRoleInputTests.cs b/tests/Aetheria.Shared.Tests/RecipeRoleInputTests.cs index f183e9e8c..16d8be24e 100644 --- a/tests/Aetheria.Shared.Tests/RecipeRoleInputTests.cs +++ b/tests/Aetheria.Shared.Tests/RecipeRoleInputTests.cs @@ -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() {