diff --git a/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs b/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs index 5f234d6ef..fd2f19be8 100644 --- a/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs +++ b/tests/Aetheria.Shared.Tests/ProductChoiceTests.cs @@ -35,7 +35,7 @@ public sealed class ProductChoiceTests : IDisposable public CultCache Cache; public ItemManager Items; public Galaxy Galaxy; - public Faction OutA, OutZ, OutBoth; + public Faction OutA, OutZ, OutBoth, OutNone; public LoadoutGenerator Outfitter(Faction faction, uint seed) { @@ -76,6 +76,7 @@ public sealed class ProductChoiceTests : IDisposable seed.Upsert(new Faction { Name = "OutA", ShortName = "OTA", Allegiance = { { alpha, 1f } } }); seed.Upsert(new Faction { Name = "OutZ", ShortName = "OTZ", Allegiance = { { zeta, 1f } } }); seed.Upsert(new Faction { Name = "OutBoth", ShortName = "OTB", Allegiance = { { alpha, 1f }, { zeta, .1f } } }); + seed.Upsert(new Faction { Name = "OutNone", ShortName = "OTN" }); var shape = new Shape(3, 3); foreach (var cell in shape.AllCoordinates) shape[cell] = true; var skiff = seed.Upsert(new HullData @@ -116,7 +117,7 @@ public sealed class ProductChoiceTests : IDisposable RunSave.Commit(cache, game, zones, new ProvenanceLedger()); return new Rig { - Cache = cache, OutA = outA, OutZ = outZ, OutBoth = cache.GetByName("OutBoth"), + Cache = cache, OutA = outA, OutZ = outZ, OutBoth = cache.GetByName("OutBoth"), OutNone = cache.GetByName("OutNone"), Items = new ItemManager(cache, new ProvenanceLedger(), RunSaveTests.TestSettings(), _ => { }), Galaxy = new Galaxy(cache, cache.GetGlobal(), _ => { }) }; @@ -151,6 +152,18 @@ public sealed class ProductChoiceTests : IDisposable Assert.Contains("lamp-z", drawn); } + // An outfitter that reaches no maker of the design gets nothing, however the weights fall: the slot fails. + [Fact] + public void AnOutfitterThatReachesNoMakerGetsNoProduct() + { + var rig = Build("lamp-z", "lamp-a"); + var generator = rig.Outfitter(rig.OutNone, 1); + Assert.Null(generator.ChooseProduct(rig.Cache.GetByName("Lamp"))); + var failures = new List(); + Assert.Null(Materialize(rig, rig.Fit(), generator.ChooseProduct, failures)); + Assert.Equal("slot 0,0: no available product of Lamp", Assert.Single(failures)); + } + [Fact] public void ANullFactionDrawIsSeededAndReachesEveryMaker() {