Tests for ButtonDimmer
This commit is contained in:
parent
a79c5d8671
commit
25c077dd04
1 changed files with 55 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue