public void AssignedWorkAffectsQuotaFactor() { var blueprint = new Blueprint("A", 1, new ItemAndQuantity("Ore/A", 10), new ItemAndQuantity("Ingot/A", 10)); var stockpiles = new IngotStockpiles(new TestIngotDefinitions { { "Ingot/A", 100 } }); var ingotWorklist = new IngotWorklist(stockpiles); var refinery = Refinery.Get(mockRefinery, new RefineryType("Refinery") { SupportedBlueprints = { "A" } }, 1); stockpiles.UpdateQuantities(new TestIngotQuantities { { "Ingot/A", 50 } }); ingotWorklist.Initialise(); IngotStockpile preferred; Assume.That(ingotWorklist.TryGetPreferred(out preferred)); Assume.That(preferred.EstimatedProduction, Is.EqualTo(0)); var initialQuotaFraction = preferred.QuotaFraction; ingotWorklist.UpdateStockpileEstimates(refinery, blueprint, 5); IngotStockpile updatedPreferred; Assume.That(ingotWorklist.TryGetPreferred(out updatedPreferred)); Assert.That(updatedPreferred.QuotaFraction, Is.GreaterThan(initialQuotaFraction)); Assert.That(updatedPreferred.EstimatedProduction, Is.GreaterThan(0)); }
public void ToleratesBlueprintsWithUnknownIngotTypes() { var blueprint = new Blueprint("A", 1, new ItemAndQuantity("Ore/A", 10), new ItemAndQuantity("Ingot/A", 10)); var stockpiles = new IngotStockpiles(new TestIngotDefinitions { { "Ingot/B", 100 } }); var ingotWorklist = new IngotWorklist(stockpiles); var refinery = Refinery.Get(mockRefinery, new RefineryType("Refinery") { SupportedBlueprints = { "A" } }, 1); stockpiles.UpdateQuantities(new TestIngotQuantities { { "Ingot/B", 20 } }); ingotWorklist.Initialise(); ingotWorklist.ScoreBlueprint(blueprint); ingotWorklist.UpdateStockpileEstimates(refinery, blueprint, 5); }
public void UpdatingStockpilesUpdatesPreferredIngotType() { var stockpiles = new IngotStockpiles(new TestIngotDefinitions { { "Ingot/A", 10 }, { "Ingot/B", 100 } }); var ingotWorklist = new IngotWorklist(stockpiles); stockpiles.UpdateQuantities(new TestIngotQuantities { { "Ingot/A", 5 }, // 50% { "Ingot/B", 10 } // 10% }); ingotWorklist.Initialise(); ingotWorklist.UpdateStockpileEstimates(Util.DefaultRefinery, Util.DefaultBlueprintProducing("Ingot/B"), 100); IngotStockpile preferred; Assert.That(ingotWorklist.TryGetPreferred(out preferred)); Assert.That(preferred.Ingot.ItemType, Is.EqualTo(new ItemType("Ingot/A"))); }
public void SkippingLastStockpileLeavesEmptyWorklist() { var stockpiles = new IngotStockpiles(new TestIngotDefinitions { { "Ingot/A", 10 }, { "Ingot/B", 100 } }); var ingotWorklist = new IngotWorklist(stockpiles); stockpiles.UpdateQuantities(new TestIngotQuantities { { "Ingot/A", 5 }, // 50% { "Ingot/B", 10 } // 10% }); ingotWorklist.Initialise(); ingotWorklist.UpdateStockpileEstimates(Util.DefaultRefinery, Util.DefaultBlueprintProducing("Ingot/B"), 100); IngotStockpile preferred; Assume.That(ingotWorklist.TryGetPreferred(out preferred)); ingotWorklist.Skip(); Assume.That(ingotWorklist.TryGetPreferred(out preferred)); ingotWorklist.Skip(); Assert.That(ingotWorklist.TryGetPreferred(out preferred), Is.False); }