ConstraintTest
This commit is contained in:
parent
beb50bad44
commit
9e05ea8c8e
1 changed files with 16 additions and 5 deletions
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.interfaces;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
|
@ -9,6 +10,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
|||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
|
@ -16,15 +18,11 @@ import info.nightscout.androidaps.utils.SP;
|
|||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class})
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class ConstraintTest {
|
||||
|
||||
@Test
|
||||
public void doTests() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
|
||||
Constraint<Boolean> b = new Constraint<>(true);
|
||||
Assert.assertEquals(Boolean.TRUE, b.value());
|
||||
Assert.assertEquals("", b.getReasons());
|
||||
|
@ -56,5 +54,18 @@ public class ConstraintTest {
|
|||
Assert.assertEquals("ConstraintTest: Set 5d\nConstraintTest: Set 6d\nConstraintTest: Set 4d", d.getReasons());
|
||||
Assert.assertEquals("ConstraintTest: Set 4d", d.getMostLimitedReasons());
|
||||
Assert.assertEquals(10d, d.originalValue());
|
||||
d.setIfDifferent(7d, "Set 7d", this);
|
||||
Assert.assertEquals(7d, d.value());
|
||||
Assert.assertEquals("ConstraintTest: Set 5d\nConstraintTest: Set 6d\nConstraintTest: Set 4d\nConstraintTest: Set 7d", d.getReasons());
|
||||
Assert.assertEquals("ConstraintTest: Set 4d\nConstraintTest: Set 7d", d.getMostLimitedReasons());
|
||||
Assert.assertEquals(10d, d.originalValue());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void prepareMock() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue