add test case for #1

Values are calculated, however not present in plot. Further research needed
master
clemens 2022-07-05 13:51:24 +02:00
parent ebfcc51eeb
commit 261ab9c4f4
4 changed files with 23 additions and 6 deletions

View File

@ -122,10 +122,10 @@ public class Test {
planFor(Database.UraniumFuelRod, 1, "fuelrod");
planFor(Database.FusedModularFrame, 100, "fusedFrame");
planFor(Database.SteelIngot, 100, "steelIngot");
planFor(Database.SteelIngot, 81.75, "steelIngot");
}
private static void planFor(Item item, int amount, String name) {
private static void planFor(Item item, double amount, String name) {
SumResult plan = SumResult.sum(new Production(item, amount));
plot2(plan.getProduction(), name);
javaPlot(name);

View File

@ -2,9 +2,9 @@ package satisfactory.items;
public class Production {
private final Item item;
private final int amount;
private final double amount;
public Production(Item item, int amount) {
public Production(Item item, double amount) {
this.item = item;
this.amount = amount;
}
@ -13,7 +13,7 @@ public class Production {
return item;
}
public int getAmount() {
public double getAmount() {
return amount;
}
}

View File

@ -176,7 +176,7 @@ public class Recipe {
return product.getRecipe().outputs.get(product) * runs;
}
public SumResult sum(Item target, int prodPerMinute) {
public SumResult sum(Item target, double prodPerMinute) {
Graph<Item, DefaultWeightedEdge> buildGraph = buildGraph(target);
Graph<Item, ProductionEdge> production = new DefaultDirectedWeightedGraph<>(ProductionEdge.class);
Map<Item, Double> map = new HashMap<>();

View File

@ -99,4 +99,21 @@ class ItemTest {
assertEquals(amount, calculations.get(item), 0.01, item.getName());
});
}
@Test
void uraniumFuelRodWithSteelIngotParents(){
Map<Item, Double> ref = new HashMap<>();
ref.put(Database.SteelIngot, 81.75);
ref.put(Database.IronOre, 81.75);
ref.put(Database.Coal, 81.75);
compareProductions(Database.UraniumFuelRod, 1, ref);
}
private void compareProductions(Item targetItem, int amount, Map<Item, Double> ref) {
Map<Item, Double> sum = SumResult.sum(new Production(targetItem, amount)).getMap();
ref.forEach((item, aDouble) -> {
assertTrue(sum.containsKey(item));
assertEquals(aDouble, sum.get(item));
});
}
}