Fixed tests
This commit is contained in:
parent
005039effc
commit
0d21a0ab62
4 changed files with 12 additions and 68 deletions
|
@ -40,7 +40,7 @@ public class HardLimits {
|
|||
public static final double MAXISF = 720; // mgdl
|
||||
|
||||
public static final double[] MAXIOB_AMA = {3, 5, 7, 12};
|
||||
public static final double[] MAXIOB_SMB = {3, 7, 20, 25};
|
||||
public static final double[] MAXIOB_SMB = {3, 7, 12, 25};
|
||||
|
||||
public static final double[] MAXBASAL = {2, 5, 10, 12};
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ConstraintsCheckerTest {
|
|||
@Test
|
||||
public void isClosedLoopAllowedTest() throws Exception {
|
||||
when(SP.getString("aps_mode", "open")).thenReturn("closed");
|
||||
objectivesPlugin.objectives.get(3).setStarted(new Date(0));
|
||||
objectivesPlugin.objectives.get(3).setStartedOn(null);
|
||||
|
||||
Constraint<Boolean> c = constraintChecker.isClosedLoopAllowed();
|
||||
Assert.assertEquals(true, c.getReasonList().size() == 2); // Safety & Objectives
|
||||
|
@ -92,7 +92,7 @@ public class ConstraintsCheckerTest {
|
|||
|
||||
@Test
|
||||
public void isAutosensModeEnabledTest() throws Exception {
|
||||
objectivesPlugin.objectives.get(5).setStarted(new Date(0));
|
||||
objectivesPlugin.objectives.get(5).setStartedOn(null);
|
||||
when(SP.getBoolean(R.string.key_openapsama_useautosens, false)).thenReturn(false);
|
||||
|
||||
Constraint<Boolean> c = constraintChecker.isAutosensModeEnabled();
|
||||
|
@ -103,7 +103,7 @@ public class ConstraintsCheckerTest {
|
|||
|
||||
@Test
|
||||
public void isAMAModeEnabledTest() throws Exception {
|
||||
objectivesPlugin.objectives.get(6).setStarted(new Date(0));
|
||||
objectivesPlugin.objectives.get(6).setStartedOn(null);
|
||||
|
||||
Constraint<Boolean> c = constraintChecker.isAMAModeEnabled();
|
||||
Assert.assertEquals(true, c.getReasonList().size() == 1); // Objectives
|
||||
|
@ -123,7 +123,7 @@ public class ConstraintsCheckerTest {
|
|||
|
||||
@Test
|
||||
public void isSMBModeEnabledTest() throws Exception {
|
||||
objectivesPlugin.objectives.get(7).setStarted(new Date(0));
|
||||
objectivesPlugin.objectives.get(7).setStartedOn(null);
|
||||
when(SP.getBoolean(R.string.key_use_smb, false)).thenReturn(false);
|
||||
when(MainApp.getConstraintChecker().isClosedLoopAllowed()).thenReturn(new Constraint<>(true));
|
||||
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.ConstraintsObjectives;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ObjectivesFragmentTest {
|
||||
|
||||
@Test
|
||||
public void testModifyVisibility() {
|
||||
|
||||
ObjectivesFragment fragment = new ObjectivesFragment();
|
||||
|
||||
int currentPosition = 1;
|
||||
long prevObjectiveAccomplishedTime = 0;
|
||||
long objectiveStartedTime = 0;
|
||||
int durationInDays = 0;
|
||||
long objectiveAccomplishedTime = 0;
|
||||
boolean requirementsMet = false;
|
||||
boolean enableFakeValue = false;
|
||||
|
||||
// previous objective is not accomplished yet
|
||||
assertEquals(0, fragment.modifyVisibility(currentPosition, prevObjectiveAccomplishedTime,
|
||||
objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));
|
||||
|
||||
// not started yet
|
||||
prevObjectiveAccomplishedTime = 4711;
|
||||
assertEquals(1, fragment.modifyVisibility(currentPosition, prevObjectiveAccomplishedTime,
|
||||
objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));
|
||||
|
||||
// started
|
||||
// time calculation is true, requirements met is false
|
||||
objectiveStartedTime = Long.MAX_VALUE;
|
||||
durationInDays = 0;
|
||||
assertEquals(2, fragment.modifyVisibility(currentPosition, prevObjectiveAccomplishedTime,
|
||||
objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));
|
||||
|
||||
// started
|
||||
// time calculation is true, requirements met is true
|
||||
objectiveStartedTime = 10;
|
||||
durationInDays = 0;
|
||||
requirementsMet = true;
|
||||
assertEquals(3, fragment.modifyVisibility(currentPosition, prevObjectiveAccomplishedTime,
|
||||
objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));
|
||||
|
||||
// finished
|
||||
objectiveStartedTime = Long.MAX_VALUE;
|
||||
durationInDays = 0;
|
||||
requirementsMet = true;
|
||||
objectiveAccomplishedTime = Long.MAX_VALUE;
|
||||
assertEquals(4, fragment.modifyVisibility(currentPosition, prevObjectiveAccomplishedTime,
|
||||
objectiveStartedTime, durationInDays, objectiveAccomplishedTime, requirementsMet, enableFakeValue));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -27,19 +27,19 @@ public class ObjectivesPluginTest {
|
|||
ObjectivesPlugin objectivesPlugin;
|
||||
|
||||
@Test
|
||||
public void notStartedObjectivesShouldLimitLoopInvokation() throws Exception {
|
||||
objectivesPlugin.objectives.get(0).setStarted(new Date(0));
|
||||
public void notStartedObjectivesShouldLimitLoopInvocation() throws Exception {
|
||||
objectivesPlugin.objectives.get(0).setStartedOn(null);
|
||||
|
||||
Constraint<Boolean> c = new Constraint<>(true);
|
||||
c = objectivesPlugin.isLoopInvocationAllowed(c);
|
||||
Assert.assertEquals("Objectives: Objective 1 not started", c.getReasons());
|
||||
Assert.assertEquals(Boolean.FALSE, c.value());
|
||||
objectivesPlugin.objectives.get(0).setStarted(new Date());
|
||||
objectivesPlugin.objectives.get(0).setStartedOn(new Date());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notStartedObjective4ShouldLimitClosedLoop() throws Exception {
|
||||
objectivesPlugin.objectives.get(3).setStarted(new Date(0));
|
||||
objectivesPlugin.objectives.get(3).setStartedOn(null);
|
||||
|
||||
Constraint<Boolean> c = new Constraint<>(true);
|
||||
c = objectivesPlugin.isClosedLoopAllowed(c);
|
||||
|
@ -49,7 +49,7 @@ public class ObjectivesPluginTest {
|
|||
|
||||
@Test
|
||||
public void notStartedObjective6ShouldLimitAutosensMode() throws Exception {
|
||||
objectivesPlugin.objectives.get(5).setStarted(new Date(0));
|
||||
objectivesPlugin.objectives.get(5).setStartedOn(null);
|
||||
|
||||
Constraint<Boolean> c = new Constraint<>(true);
|
||||
c = objectivesPlugin.isAutosensModeEnabled(c);
|
||||
|
@ -59,7 +59,7 @@ public class ObjectivesPluginTest {
|
|||
|
||||
@Test
|
||||
public void notStartedObjective7ShouldLimitAMAMode() throws Exception {
|
||||
objectivesPlugin.objectives.get(6).setStarted(new Date(0));
|
||||
objectivesPlugin.objectives.get(6).setStartedOn(null);
|
||||
|
||||
Constraint<Boolean> c = new Constraint<>(true);
|
||||
c = objectivesPlugin.isAMAModeEnabled(c);
|
||||
|
@ -69,7 +69,7 @@ public class ObjectivesPluginTest {
|
|||
|
||||
@Test
|
||||
public void notStartedObjective8ShouldLimitSMBMode() throws Exception {
|
||||
objectivesPlugin.objectives.get(7).setStarted(new Date(0));
|
||||
objectivesPlugin.objectives.get(7).setStartedOn(null);
|
||||
|
||||
Constraint<Boolean> c = new Constraint<>(true);
|
||||
c = objectivesPlugin.isSMBModeEnabled(c);
|
||||
|
|
Loading…
Reference in a new issue