KnobDimmer Tests

This commit is contained in:
omenem 2020-03-17 17:45:50 +01:00
parent 5e7bd298de
commit ce0edd7287

View file

@ -0,0 +1,46 @@
package ch.usi.inf.sa4.sanmarinoes.smarthut;
import static org.junit.jupiter.api.Assertions.*;
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight;
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.KnobDimmer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@DisplayName("A Knob Dimmer")
public class KnobDimmerTests {
KnobDimmer knobDimmer;
@BeforeEach
public void createNewKnobDimmer() {
this.knobDimmer = new KnobDimmer();
}
@Nested
@DisplayName(" when multiple lights are present")
class MultipleLights {
@BeforeEach
public void setLights() {
DimmableLight dl;
for (int i = 0; i < 3; i++) {
dl = new DimmableLight();
dl.setIntensity(10);
;
knobDimmer.addDimmableLight(dl);
}
}
@Test
@DisplayName(" set the intensity ")
public void increase() {
knobDimmer.setLightIntensity(30);
for (DimmableLight dl : knobDimmer.getOutputs()) {
assertEquals(30, dl.getIntensity());
}
}
}
}