AndroidAPS/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintTest.java

36 lines
1,015 B
Java
Raw Normal View History

package info.nightscout.androidaps.interfaces;
2018-03-19 13:11:25 +01:00
import junit.framework.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;
import info.nightscout.androidaps.interfaces.Constraint;
2018-03-19 13:11:25 +01:00
/**
* Created by mike on 19.03.2018.
*/
@RunWith(PowerMockRunner.class)
2018-03-19 17:38:48 +01:00
public class ConstraintTest {
2018-03-19 13:11:25 +01:00
@Test
public void doTests() throws Exception {
2018-03-19 17:38:48 +01:00
Constraint<Boolean> c;
2018-03-19 13:11:25 +01:00
2018-03-19 17:38:48 +01:00
c = new Constraint<Boolean>(true);
Assert.assertEquals(Boolean.TRUE, c.get());
2018-03-19 13:11:25 +01:00
Assert.assertEquals("", c.getReasons());
c.set(false);
2018-03-19 17:38:48 +01:00
Assert.assertEquals(Boolean.FALSE, c.get());
2018-03-19 13:11:25 +01:00
Assert.assertEquals("", c.getReasons());
c.set(true, "Set true");
2018-03-19 17:38:48 +01:00
Assert.assertEquals(Boolean.TRUE, c.get());
2018-03-19 13:11:25 +01:00
Assert.assertEquals("Set true", c.getReasons());
2018-03-19 17:38:48 +01:00
c.set(false, "Set false");
Assert.assertEquals(Boolean.FALSE, c.get());
Assert.assertEquals("Set true\nSet false", c.getReasons());
2018-03-19 13:11:25 +01:00
}
}