add test helper
parent
261ab9c4f4
commit
6bb38066d6
|
|
@ -1,11 +1,10 @@
|
|||
package satisfactory.items;
|
||||
|
||||
import org.jgrapht.Graph;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import satisfactory.Database;
|
||||
import satisfactory.Utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
|
@ -14,36 +13,28 @@ class ItemTest {
|
|||
|
||||
@Test
|
||||
void productionScrews() {
|
||||
/*Map<Item, Double> production = Database.Screw.production(100);
|
||||
assertEquals(100, production.get(Database.Screw), "Screws (output)");
|
||||
assertEquals(25, production.get(Database.IronRod), "IronRod");
|
||||
assertEquals(25, production.get(Database.IronIngot), "IronIngot");
|
||||
assertEquals(25, production.get(Database.IronOre), "IronOre");*/
|
||||
fail();
|
||||
}
|
||||
|
||||
@Test
|
||||
void productionScrews2() {
|
||||
/*Map<Item, Double> production = Database.Screw.getRecipe().sum(Database.Screw, 100);
|
||||
assertEquals(100, production.get(Database.Screw), "Screws (output)");
|
||||
assertEquals(25, production.get(Database.IronRod), "IronRod");
|
||||
assertEquals(25, production.get(Database.IronIngot), "IronIngot");
|
||||
assertEquals(25, production.get(Database.IronOre), "IronOre");
|
||||
|
||||
*/
|
||||
fail("TODO: migrate");
|
||||
Collection<Ref> ref = Arrays.asList(
|
||||
new Ref(Database.Screw, 100.0),
|
||||
new Ref(Database.IronRod, 25.0),
|
||||
new Ref(Database.IronIngot, 25.0),
|
||||
new Ref(Database.IronOre, 25.0)
|
||||
);
|
||||
SumResult sum = SumResult.sum(new Production(Database.Screw, 100.0));
|
||||
compareProductions(sum, ref);
|
||||
}
|
||||
|
||||
@Test
|
||||
void productionReinforcedIronPlates() {
|
||||
/*Map<Item, Double> production = Database.ReinforcedIronPlate.production(100);
|
||||
assertEquals(100, production.get(Database.ReinforcedIronPlate), "output");
|
||||
assertEquals(1200, production.get(Database.Screw), "Screws");
|
||||
assertEquals(300, production.get(Database.IronRod), "IronRod");
|
||||
assertEquals(1200, production.get(Database.IronIngot), "IronIngot");
|
||||
assertEquals(1200, production.get(Database.IronOre), "IronOre");
|
||||
assertEquals(600, production.get(Database.IronPlate), "IronPlate");*/
|
||||
fail();
|
||||
Collection<Ref> ref = Arrays.asList(
|
||||
new Ref(Database.ReinforcedIronPlate, 100.0, "output"),
|
||||
new Ref(Database.Screw, 1200.0),
|
||||
new Ref(Database.IronRod, 300.0),
|
||||
new Ref(Database.IronIngot, 1200.0),
|
||||
new Ref(Database.IronOre, 1200.0),
|
||||
new Ref(Database.IronPlate, 600.0)
|
||||
);
|
||||
SumResult sum = SumResult.sum(new Production(Database.ReinforcedIronPlate, 100.0));
|
||||
compareProductions(sum, ref);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -55,65 +46,84 @@ class ItemTest {
|
|||
@Test
|
||||
void testPhase3_ME_ACU() {
|
||||
// references
|
||||
Map<Item, Double> ref = new HashMap<>();
|
||||
ref.put(Database.CircuitBoard, 15.0);
|
||||
ref.put(Database.Computer, 1.0);
|
||||
ref.put(Database.Limestone,75.0);
|
||||
ref.put(Database.Concrete,25.0);
|
||||
ref.put(Database.SteelBeam,20.0);
|
||||
ref.put(Database.EncasedIndustrialBeam, 5.0);
|
||||
ref.put(Database.ModularFrame,5.0);
|
||||
ref.put(Database.HeavyModularFrame,1.0);
|
||||
ref.put(Database.Plastic, 78.0);
|
||||
ref.put(Database.CopperSheet, 30.0);
|
||||
ref.put(Database.Coal,226.25);
|
||||
ref.put(Database.Cable,159.0);
|
||||
ref.put(Database.CopperOre,329.0);
|
||||
ref.put(Database.AutomatedWiring, 7.5);
|
||||
ref.put(Database.AdaptiveControlUnit, 1.0);
|
||||
ref.put(Database.CrudeOil, 229.5);
|
||||
ref.put(Database.ReinforcedIronPlate, 17.5);
|
||||
ref.put(Database.CopperIngot, 329.0);
|
||||
ref.put(Database.SteelIngot, 226.25);
|
||||
ref.put(Database.IronPlate, 105.0);
|
||||
ref.put(Database.SmartPlating, 10.0);
|
||||
//ref.put(Database.HeavyOilResidue, 114.0); // TODO: implement calculation
|
||||
ref.put(Database.Rubber, 75.0);
|
||||
ref.put(Database.Wire, 538.0);
|
||||
ref.put(Database.SteelPipe, 97.5);
|
||||
ref.put(Database.Stator, 27.5);
|
||||
ref.put(Database.Screw, 1112.0);
|
||||
ref.put(Database.IronOre, 841.75);
|
||||
ref.put(Database.IronIngot, 615.5);
|
||||
ref.put(Database.IronRod, 458.0);
|
||||
ref.put(Database.Rotor, 30.0);
|
||||
ref.put(Database.Motor, 10.0);
|
||||
ref.put(Database.ModularEngine, 5.0);
|
||||
Collection<Ref> ref = Arrays.asList(
|
||||
new Ref(Database.CircuitBoard, 15.0),
|
||||
new Ref(Database.Computer, 1.0),
|
||||
new Ref(Database.Limestone, 75.0),
|
||||
new Ref(Database.Concrete, 25.0),
|
||||
new Ref(Database.SteelBeam, 20.0),
|
||||
new Ref(Database.EncasedIndustrialBeam, 5.0),
|
||||
new Ref(Database.ModularFrame, 5.0),
|
||||
new Ref(Database.HeavyModularFrame, 1.0),
|
||||
new Ref(Database.Plastic, 78.0),
|
||||
new Ref(Database.CopperSheet, 30.0),
|
||||
new Ref(Database.Coal, 226.25),
|
||||
new Ref(Database.Cable, 159.0),
|
||||
new Ref(Database.CopperOre, 329.0),
|
||||
new Ref(Database.AutomatedWiring, 7.5),
|
||||
new Ref(Database.AdaptiveControlUnit, 1.0),
|
||||
new Ref(Database.CrudeOil, 229.5),
|
||||
new Ref(Database.ReinforcedIronPlate, 17.5),
|
||||
new Ref(Database.CopperIngot, 329.0),
|
||||
new Ref(Database.SteelIngot, 226.25),
|
||||
new Ref(Database.IronPlate, 105.0),
|
||||
new Ref(Database.SmartPlating, 10.0),
|
||||
//new Ref(Database.HeavyOilResidue, 114.0), // TODO: implement calculation
|
||||
new Ref(Database.Rubber, 75.0),
|
||||
new Ref(Database.Wire, 538.0),
|
||||
new Ref(Database.SteelPipe, 97.5),
|
||||
new Ref(Database.Stator, 27.5),
|
||||
new Ref(Database.Screw, 1112.0),
|
||||
new Ref(Database.IronOre, 841.75),
|
||||
new Ref(Database.IronIngot, 615.5),
|
||||
new Ref(Database.IronRod, 458.0),
|
||||
new Ref(Database.Rotor, 30.0),
|
||||
new Ref(Database.Motor, 10.0),
|
||||
new Ref(Database.ModularEngine, 5.0)
|
||||
);
|
||||
|
||||
// calculate
|
||||
Map<Item, Double> calculations = SumResult.sum(new Production(Database.ModularEngine, 5), new Production(Database.AdaptiveControlUnit, 1)).getMap();
|
||||
SumResult sum = SumResult.sum(new Production(Database.ModularEngine, 5), new Production(Database.AdaptiveControlUnit, 1));
|
||||
|
||||
// assert
|
||||
ref.forEach((item, amount) -> {
|
||||
assertTrue(calculations.containsKey(item), "exists? " + item.getName());
|
||||
assertEquals(amount, calculations.get(item), 0.01, item.getName());
|
||||
});
|
||||
compareProductions(sum, ref);
|
||||
fail("Something heavy oil residue");
|
||||
}
|
||||
|
||||
@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);
|
||||
void uraniumFuelRodWithSteelIngotParents() {
|
||||
Collection<Ref> refs = Arrays.asList(
|
||||
new Ref(Database.SteelIngot, 81.75),
|
||||
new Ref(Database.IronOre, 81.75),
|
||||
new Ref(Database.Coal, 81.75)
|
||||
);
|
||||
SumResult sums = SumResult.sum(new Production(Database.UraniumFuelRod, 1.0));
|
||||
compareProductions(sums, refs);
|
||||
}
|
||||
|
||||
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));
|
||||
private void compareProductions(SumResult sum, Collection<Ref> references) {
|
||||
Map<Item, Double> inputs = sum.getMap();
|
||||
references.forEach(ref -> {
|
||||
assertTrue(inputs.containsKey(ref.item), ref.note);
|
||||
assertEquals(ref.amount, inputs.get(ref.item), ref.note);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class Ref {
|
||||
Item item;
|
||||
double amount;
|
||||
String note;
|
||||
|
||||
public Ref(Item item, double amount, String note) {
|
||||
this.item = item;
|
||||
this.amount = amount;
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public Ref(Item item, double amount) {
|
||||
this.item = item;
|
||||
this.amount = amount;
|
||||
note = item.getName();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue