diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/SmartPlugTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/SmartPlugTests.java new file mode 100644 index 0000000..921979e --- /dev/null +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/SmartPlugTests.java @@ -0,0 +1,43 @@ +package ch.usi.inf.sa4.sanmarinoes.smarthut; + +import static org.junit.jupiter.api.Assertions.*; + +import ch.usi.inf.sa4.sanmarinoes.smarthut.models.SmartPlug; +import java.math.BigDecimal; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +@DisplayName("SmartPlug Tests") +public class SmartPlugTests { + + private SmartPlug smartPlug; + + @BeforeEach + public void createSmartPlug() { + this.smartPlug = new SmartPlug(); + } + + @Test + @DisplayName("set and get on") + public void testOn() { + smartPlug.setOn(true); + + assertTrue(smartPlug.isOn()); + } + + @Test + @DisplayName("read trigger state") + public void readTriggerState() { + smartPlug.setOn(true); + + assertTrue(smartPlug.readTriggerState()); + } + + @Test + @DisplayName("reset total consumption") + public void reset() { + + assertEquals(new BigDecimal(0), smartPlug.getTotalConsumption()); + } +} diff --git a/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/SwitchableStateTests.java b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/SwitchableStateTests.java new file mode 100644 index 0000000..c89e04f --- /dev/null +++ b/src/test/java/ch/usi/inf/sa4/sanmarinoes/smarthut/SwitchableStateTests.java @@ -0,0 +1,28 @@ +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.SwitchableState; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +@DisplayName("Switchable State Tests") +public class SwitchableStateTests { + + private SwitchableState switchableState; + + @BeforeEach + public void createSwitchableState() { + switchableState = new SwitchableState<>(); + } + + @Test + @DisplayName("is on") + public void isOn() { + switchableState.setOn(true); + + assertTrue(switchableState.isOn()); + } +}