diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/ButtonDimmerTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/ButtonDimmerTests.java new file mode 100644 index 0000000..85f4e49 --- /dev/null +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/ButtonDimmerTests.java @@ -0,0 +1,55 @@ +package ch.usi.inf.sa4.sanmarinoes.smarthut; + +import static org.junit.jupiter.api.Assertions.*; + +import ch.usi.inf.sa4.sanmarinoes.smarthut.models.ButtonDimmer; +import ch.usi.inf.sa4.sanmarinoes.smarthut.models.DimmableLight; +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 Button Dimmer") +public class ButtonDimmerTests { + + ButtonDimmer buttonDimmer; + + @BeforeEach + public void createNewButtonDimmer() { + this.buttonDimmer = new ButtonDimmer(); + } + + @Nested + @DisplayName(" when lights are present") + class lightsPresent { + + @BeforeEach + public void setLights() { + DimmableLight dl; + for (int i = 0; i < 3; i++) { + dl = new DimmableLight(); + dl.setIntensity(10); + ; + buttonDimmer.addDimmableLight(dl); + } + } + + @Test + @DisplayName(" increase the intensity ") + public void increase() { + buttonDimmer.increaseIntensity(); + for (DimmableLight dl : buttonDimmer.getOutputs()) { + assertTrue(dl.getIntensity() > 10); + } + } + + @Test + @DisplayName(" decrease the intensity ") + public void decrease() { + buttonDimmer.decreaseIntensity(); + for (DimmableLight dl : buttonDimmer.getOutputs()) { + assertTrue(dl.getIntensity() < 10); + } + } + } +}