42 lines
1.1 KiB
Java
42 lines
1.1 KiB
Java
package de.ph87.electro.circuit;
|
|
|
|
import de.ph87.electro.circuit.part.parts.PartBattery;
|
|
import de.ph87.electro.circuit.part.parts.PartLight;
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
|
public class BatteryLightTest {
|
|
|
|
private static final double VOLTAGE = 3;
|
|
|
|
private static final Circuit CIRCUIT = new Circuit();
|
|
|
|
private static final PartBattery battery = CIRCUIT.addPart(new PartBattery());
|
|
|
|
private static final PartLight light = CIRCUIT.addPart(new PartLight());
|
|
|
|
@BeforeAll
|
|
public static void setUp() {
|
|
CIRCUIT.connect(battery.getPlus(), light.getB());
|
|
CIRCUIT.connect(light.getA(), battery.getMinus());
|
|
}
|
|
|
|
@Test
|
|
void test() {
|
|
CIRCUIT.evaluateAndRender();
|
|
|
|
assertEquals(VOLTAGE, battery.getPlus().getVoltage());
|
|
assertEquals(VOLTAGE, light.getB().getVoltage());
|
|
assertEquals(VOLTAGE, light.getPotentialDifference());
|
|
|
|
assertEquals(0, light.getA().getVoltage());
|
|
assertEquals(0, battery.getMinus().getVoltage());
|
|
|
|
assertFalse(light.isDefect());
|
|
}
|
|
|
|
}
|