more tests

This commit is contained in:
omenem 2020-05-16 18:00:28 +02:00
parent 7020f0d692
commit 3f568c77d3
2 changed files with 71 additions and 0 deletions

View file

@ -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());
}
}

View file

@ -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<DimmableLight> switchableState;
@BeforeEach
public void createSwitchableState() {
switchableState = new SwitchableState<>();
}
@Test
@DisplayName("is on")
public void isOn() {
switchableState.setOn(true);
assertTrue(switchableState.isOn());
}
}