Added UTests for PumpUtil and VirualPlugin (new methods)
This commit is contained in:
parent
347d210d06
commit
2600a7009b
2 changed files with 123 additions and 0 deletions
|
@ -0,0 +1,45 @@
|
|||
package info.nightscout.androidaps.plugins.PumpCommon.utils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpCapability;
|
||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpTempBasalType;
|
||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by andy on 5/13/18.
|
||||
*/
|
||||
public class PumpUtilUTest {
|
||||
|
||||
@Test
|
||||
public void setPumpDescription() throws Exception {
|
||||
|
||||
PumpDescription pumpDescription = new PumpDescription();
|
||||
|
||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.AccuChekCombo);
|
||||
|
||||
Assert.assertEquals(pumpDescription.bolusStep, PumpType.AccuChekCombo.getBolusSize(), 0.1d);
|
||||
Assert.assertEquals(pumpDescription.basalMinimumRate, PumpType.AccuChekCombo.getBaseBasalStep(), 0.1d);
|
||||
Assert.assertEquals(pumpDescription.basalStep, PumpType.AccuChekCombo.getBaseBasalStep(), 0.1d);
|
||||
Assert.assertEquals(pumpDescription.extendedBolusDurationStep, PumpType.AccuChekCombo.getExtendedBolusSettings().getDurationStep(), 0.1d);
|
||||
Assert.assertEquals(pumpDescription.extendedBolusMaxDuration, PumpType.AccuChekCombo.getExtendedBolusSettings().getMaxDuration(), 0.1d);
|
||||
Assert.assertEquals(pumpDescription.extendedBolusStep, PumpType.AccuChekCombo.getExtendedBolusSettings().getStep(), 0.1d);
|
||||
Assert.assertEquals(pumpDescription.isExtendedBolusCapable, PumpType.AccuChekCombo.getPumpCapability().hasCapability(PumpCapability.ExtendedBolus));
|
||||
Assert.assertEquals(pumpDescription.isBolusCapable, PumpType.AccuChekCombo.getPumpCapability().hasCapability(PumpCapability.Bolus));
|
||||
Assert.assertEquals(pumpDescription.isRefillingCapable, PumpType.AccuChekCombo.getPumpCapability().hasCapability(PumpCapability.Refill));
|
||||
Assert.assertEquals(pumpDescription.isSetBasalProfileCapable, PumpType.AccuChekCombo.getPumpCapability().hasCapability(PumpCapability.BasalProfileSet));
|
||||
Assert.assertEquals(pumpDescription.isTempBasalCapable, PumpType.AccuChekCombo.getPumpCapability().hasCapability(PumpCapability.TempBasal));
|
||||
Assert.assertEquals(pumpDescription.maxTempPercent, PumpType.AccuChekCombo.getTbrSettings().getMaxDose(), 0.1d);
|
||||
Assert.assertEquals(pumpDescription.tempPercentStep, PumpType.AccuChekCombo.getTbrSettings().getStep(), 0.1d);
|
||||
Assert.assertEquals(pumpDescription.tempBasalStyle, PumpType.AccuChekCombo.getPumpTempBasalType()== PumpTempBasalType.Percent ? PumpDescription.PERCENT : PumpDescription.ABSOLUTE);
|
||||
Assert.assertEquals(pumpDescription.tempDurationStep, PumpType.AccuChekCombo.getTbrSettings().getDurationStep());
|
||||
Assert.assertEquals(pumpDescription.tempDurationStep15mAllowed, PumpType.AccuChekCombo.getSpecialBasalDurations().hasCapability(PumpCapability.BasalRate_Duration15minAllowed));
|
||||
Assert.assertEquals(pumpDescription.tempDurationStep30mAllowed, PumpType.AccuChekCombo.getSpecialBasalDurations().hasCapability(PumpCapability.BasalRate_Duration30minAllowed));
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package info.nightscout.androidaps.plugins.PumpVirtual;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||
import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
|
||||
/**
|
||||
* Created by andy on 5/13/18.
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, ToastUtils.class, Context.class, SP.class})
|
||||
public class VirtualPumpPluginUTest {
|
||||
|
||||
|
||||
VirtualPumpPlugin virtualPumpPlugin;
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void prepareMocks() throws Exception {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockConfigBuilder();
|
||||
AAPSMocker.mockBus();
|
||||
AAPSMocker.mockStrings();
|
||||
AAPSMocker.mockCommandQueue();
|
||||
AAPSMocker.mockSP();
|
||||
|
||||
virtualPumpPlugin = VirtualPumpPlugin.getPlugin();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getPumpType() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refreshConfiguration() throws Exception {
|
||||
|
||||
when(SP.getString("virtualpump_type", "Generic AAPS")).thenReturn("Accu-Chek Combo");
|
||||
|
||||
virtualPumpPlugin.refreshConfiguration();
|
||||
|
||||
Assert.assertEquals(PumpType.AccuChekCombo, virtualPumpPlugin.getPumpType());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void refreshConfigurationTwice() throws Exception {
|
||||
|
||||
when(SP.getString("virtualpump_type", "Generic AAPS")).thenReturn("Accu-Chek Combo");
|
||||
|
||||
virtualPumpPlugin.refreshConfiguration();
|
||||
|
||||
when(SP.getString("virtualpump_type", "Generic AAPS")).thenReturn("Accu-Chek Combo");
|
||||
|
||||
virtualPumpPlugin.refreshConfiguration();
|
||||
|
||||
Assert.assertEquals(PumpType.AccuChekCombo, virtualPumpPlugin.getPumpType());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue