Dana messages tests
This commit is contained in:
parent
50bbe1c481
commit
c283531348
77 changed files with 822 additions and 1814 deletions
|
@ -24,7 +24,7 @@ import info.nightscout.androidaps.utils.CRC;
|
|||
|
||||
public class MessageBase {
|
||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
||||
protected byte[] buffer = new byte[512];
|
||||
public byte[] buffer = new byte[512];
|
||||
private int position = 6;
|
||||
|
||||
public boolean received = false;
|
||||
|
|
|
@ -27,6 +27,7 @@ class MsgInitConnStatusBolus(
|
|||
failed = true
|
||||
return
|
||||
}
|
||||
failed = false
|
||||
val bolusConfig = intFromBuff(bytes, 0, 1)
|
||||
danaRPump.isExtendedBolusEnabled = bolusConfig and 0x01 != 0
|
||||
danaRPump.bolusStep = intFromBuff(bytes, 1, 1) / 100.0
|
||||
|
|
|
@ -35,6 +35,7 @@ class MsgInitConnStatusOption(
|
|||
//val lowReservoirAlarmBoundary = intFromBuff(bytes, 7, 1)
|
||||
//int none = intFromBuff(bytes, 8, 1);
|
||||
if (bytes.size >= 21) {
|
||||
failed = false
|
||||
danaRPump.password = intFromBuff(bytes, 9, 2) xor 0x3463
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Pump password: " + danaRPump.password)
|
||||
} else {
|
||||
|
|
|
@ -11,8 +11,8 @@ class MsgSetAPSTempBasalStart_v2(
|
|||
thirtyMinutes: Boolean
|
||||
) : MessageBase() {
|
||||
|
||||
private val PARAM30MIN = 160
|
||||
private val PARAM15MIN = 150
|
||||
val PARAM30MIN = 160
|
||||
val PARAM15MIN = 150
|
||||
|
||||
init {
|
||||
SetCommand(0xE002)
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgInitConnStatusBasicTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgInitConnStatusBasic packet = new MsgInitConnStatusBasic();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(true, pump.pumpSuspended);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgInitConnStatusBasicTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgInitConnStatusBasic(aapsLogger, danaRPump)
|
||||
|
||||
// test message decoding
|
||||
val array = ByteArray(100)
|
||||
|
||||
putByteToArray(array, 0, 1)
|
||||
packet.handleMessage(array)
|
||||
Assert.assertEquals(true, danaRPump.pumpSuspended)
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgInitConnStatusBolusTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgInitConnStatusBolus packet = new MsgInitConnStatusBolus();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
// message bigger than 22
|
||||
assertEquals(true, packet.failed);
|
||||
packet.handleMessage(createArray(20, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(true, pump.isExtendedBolusEnabled);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgInitConnStatusBolusTest : DanaRTestBase() {
|
||||
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgInitConnStatusBolus(aapsLogger, RxBusWrapper(), resourceHelper, danaRPump)
|
||||
|
||||
// test message decoding
|
||||
var array = ByteArray(100)
|
||||
|
||||
// message bigger than 22
|
||||
packet.handleMessage(array)
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
array = ByteArray(20)
|
||||
putByteToArray(array, 0, 1)
|
||||
packet.handleMessage(array)
|
||||
Assert.assertEquals(true, danaRPump.isExtendedBolusEnabled)
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, ConfigBuilderPlugin.class})
|
||||
public class MsgInitConnStatusOptionTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockConfigBuilder();
|
||||
MsgInitConnStatusOption packet = new MsgInitConnStatusOption();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(20, (byte) 1));
|
||||
// message smaller than 21
|
||||
assertEquals(true, packet.failed);
|
||||
packet.handleMessage(createArray(22, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(false, pump.isPasswordOK());
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.api.mockito.PowerMockito
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(VirtualPumpPlugin::class)
|
||||
class MsgInitConnStatusOptionTest : DanaRTestBase() {
|
||||
|
||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
||||
@Test fun runTest() {
|
||||
`when`(activePlugin.activePump).thenReturn(PowerMockito.mock(VirtualPumpPlugin::class.java))
|
||||
val packet = MsgInitConnStatusOption(aapsLogger, RxBusWrapper(), resourceHelper, danaRPump, activePlugin)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(20, 1.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
// message smaller than 21
|
||||
packet.handleMessage(createArray(22, 1.toByte()))
|
||||
Assert.assertEquals(false, danaRPump.isPasswordOK)
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, ConfigBuilderPlugin.class})
|
||||
public class MsgInitConnStatusTimeTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
MsgInitConnStatusTime packet = new MsgInitConnStatusTime();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(20, (byte) 1));
|
||||
// message smaller than 10
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(createArray(15, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void mock() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockConfigBuilder();
|
||||
AAPSMocker.mockCommandQueue();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
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
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(DanaRKoreanPlugin::class, DanaRPlugin::class)
|
||||
class MsgInitConnStatusTimeTest : DanaRTestBase() {
|
||||
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var danaRPlugin: DanaRPlugin
|
||||
@Mock lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
||||
@Mock lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||
@Mock lateinit var commandQueue: CommandQueueProvider
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgInitConnStatusTime(aapsLogger, RxBusWrapper(), resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(20, 1.toByte()))
|
||||
Assert.assertEquals(false, packet.failed)
|
||||
// message smaller than 10
|
||||
packet.handleMessage(createArray(15, 1.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgPCCommStartTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgPCCommStart packet = new MsgPCCommStart();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgPCCommStartTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgPCCommStart(aapsLogger)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgPCCommStopTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgPCCommStop packet = new MsgPCCommStop();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgPCCommStopTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgPCCommStop(aapsLogger)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetActivateBasalProfileTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetActivateBasalProfile packet = new MsgSetActivateBasalProfile((byte) 1);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSetActivateBasalProfileTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSetActivateBasalProfile(aapsLogger, 1.toByte())
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetBasalProfileTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetBasalProfile packet = new MsgSetBasalProfile((byte) 1, createArray(24,1));
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 2));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSetBasalProfileTest : DanaRTestBase() {
|
||||
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSetBasalProfile(aapsLogger, RxBusWrapper(), resourceHelper, 1.toByte(), Array(24) { 1.0 })
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 2.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetCarbsEntryTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetCarbsEntry packet = new MsgSetCarbsEntry(System.currentTimeMillis(), 10);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSetCarbsEntryTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSetCarbsEntry(aapsLogger, System.currentTimeMillis(), 10)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetExtendedBolusStartTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockConstraintsChecker();
|
||||
MsgSetExtendedBolusStart packet = new MsgSetExtendedBolusStart(2D, (byte) 2);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(ConstraintChecker::class)
|
||||
class MsgSetExtendedBolusStartTest : DanaRTestBase() {
|
||||
|
||||
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||
|
||||
@Test fun runTest() {
|
||||
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||
val packet = MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 2.0, 2.toByte())
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetExtendedBolusStopTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetExtendedBolusStop packet = new MsgSetExtendedBolusStop();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSetExtendedBolusStopTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSetExtendedBolusStop(aapsLogger)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetSingleBasalProfileTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetSingleBasalProfile packet = new MsgSetSingleBasalProfile(createArray(24, 2));
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSetSingleBasalProfileTest : DanaRTestBase() {
|
||||
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSetSingleBasalProfile(aapsLogger, RxBusWrapper(), resourceHelper, createArray(24, 2.0))
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetTempBasalStartTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetTempBasalStart packet = new MsgSetTempBasalStart(250, 1);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSetTempBasalStartTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSetTempBasalStart(aapsLogger, 250, 1)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetTempBasalStopTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetTempBasalStop packet = new MsgSetTempBasalStop();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetTimeTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetTime packet = new MsgSetTime(new Date(System.currentTimeMillis()));
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
import java.util.*
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSetTimeTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSetTime(aapsLogger, Date(System.currentTimeMillis()))
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetUserOptionsTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetUserOptions packet = new MsgSetUserOptions();
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSetUserOptionsTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSetUserOptions(aapsLogger, danaRPump)
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingActiveProfileTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingActiveProfile packet = new MsgSettingActiveProfile();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(MessageBase.intFromBuff(createArray(34, (byte) 7), 0, 1), pump.activeProfile);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSettingActiveProfileTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSettingActiveProfile(aapsLogger, danaRPump)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(MessageBase.intFromBuff(createArray(34, 7.toByte()), 0, 1), danaRPump.activeProfile)
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingBasalProfileAllTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingBasalProfileAll packet = new MsgSettingBasalProfileAll();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(400, (byte) 1));
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSettingBasalProfileAllTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSettingBasalProfileAll(aapsLogger, danaRPump)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(400, 1.toByte()))
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingBasalTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingBasal packet = new MsgSettingBasal();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(100, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
int expected = MessageBase.intFromBuff(createArray(100, (byte) 1), 2 * 1, 2);
|
||||
assertEquals((double) expected/100d, pump.pumpProfiles[pump.activeProfile][1], 0);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(DanaRPlugin::class)
|
||||
class MsgSettingBasalTest : DanaRTestBase() {
|
||||
|
||||
@Mock lateinit var danaRPlugin: DanaRPlugin
|
||||
|
||||
@Test fun runTest() {
|
||||
`when`(danaRPlugin.getPumpDescription()).thenReturn(PumpDescription())
|
||||
val packet = MsgSettingBasal(aapsLogger, danaRPump, danaRPlugin)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(100, 1.toByte()))
|
||||
val expected = MessageBase.intFromBuff(createArray(100, 1.toByte()), 2 * 1, 2)
|
||||
Assert.assertEquals(expected.toDouble() / 100.0, danaRPump.pumpProfiles!![danaRPump.activeProfile][1], 0.0)
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingGlucoseTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingGlucose packet = new MsgSettingGlucose();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(1, pump.units);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSettingGlucoseTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSettingGlucose(aapsLogger, danaRPump)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
Assert.assertEquals(1, danaRPump.units)
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingMaxValuesTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingMaxValues packet = new MsgSettingMaxValues();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 0, 2) / 100d, pump.maxBolus,0);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSettingMaxValuesTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSettingMaxValues(aapsLogger, danaRPump)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(MessageBase.intFromBuff(createArray(10, 7.toByte()), 0, 2).toDouble() / 100.0, danaRPump.maxBolus, 0.0)
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingMealTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingMeal packet = new MsgSettingMeal();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 1), 0, 1) / 100d, pump.bolusStep, 0);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
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
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(DanaRPlugin::class, DanaRKoreanPlugin::class)
|
||||
class MsgSettingMealTest : DanaRTestBase() {
|
||||
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var danaRPlugin: DanaRPlugin
|
||||
@Mock lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSettingMeal(aapsLogger, RxBusWrapper(), resourceHelper, danaRPump, danaRKoreanPlugin)
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
Assert.assertEquals(MessageBase.intFromBuff(createArray(10, 1.toByte()), 0, 1).toDouble() / 100.0, danaRPump.bolusStep, 0.0)
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingProfileRatiosAllTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingProfileRatiosAll packet = new MsgSettingProfileRatiosAll();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.units = DanaRPump.UNITS_MGDL;
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 0, 2), pump.morningCIR,0);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSettingProfileRatiosAllTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSettingProfileRatiosAll(aapsLogger, danaRPump)
|
||||
danaRPump.units = DanaRPump.UNITS_MGDL
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(MessageBase.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaRPump.morningCIR)
|
||||
}
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingProfileRatiosTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingProfileRatios packet = new MsgSettingProfileRatios();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.units = DanaRPump.UNITS_MGDL;
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 0, 2), pump.currentCIR,0);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSettingProfileRatiosTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSettingProfileRatios(aapsLogger, danaRPump)
|
||||
danaRPump.units = DanaRPump.UNITS_MGDL
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(MessageBase.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaRPump.currentCIR)
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingPumpTimeTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingPumpTime packet = new MsgSettingPumpTime();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.units = DanaRPump.UNITS_MGDL;
|
||||
// test message decoding
|
||||
byte[] bytes = createArray(34, (byte) 7);
|
||||
long time =
|
||||
new Date(
|
||||
100 + MessageBase.intFromBuff(bytes, 5, 1),
|
||||
MessageBase.intFromBuff(bytes, 4, 1) - 1,
|
||||
MessageBase.intFromBuff(bytes, 3, 1),
|
||||
MessageBase.intFromBuff(bytes, 2, 1),
|
||||
MessageBase.intFromBuff(bytes, 1, 1),
|
||||
MessageBase.intFromBuff(bytes, 0, 1)
|
||||
).getTime();
|
||||
packet.handleMessage(bytes);
|
||||
pump = DanaRPump.getInstance();
|
||||
assertEquals(time, pump.pumpTime);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
import java.util.*
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSettingPumpTimeTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSettingPumpTime(aapsLogger, danaRPump)
|
||||
danaRPump.units = DanaRPump.UNITS_MGDL
|
||||
// test message decoding
|
||||
val bytes = createArray(34, 7.toByte())
|
||||
val time = Date(
|
||||
100 + MessageBase.intFromBuff(bytes, 5, 1),
|
||||
MessageBase.intFromBuff(bytes, 4, 1) - 1,
|
||||
MessageBase.intFromBuff(bytes, 3, 1),
|
||||
MessageBase.intFromBuff(bytes, 2, 1),
|
||||
MessageBase.intFromBuff(bytes, 1, 1),
|
||||
MessageBase.intFromBuff(bytes, 0, 1)
|
||||
).time
|
||||
packet.handleMessage(bytes)
|
||||
Assert.assertEquals(time, danaRPump.pumpTime)
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingShippingInfoTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingShippingInfo packet = new MsgSettingShippingInfo();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.units = DanaRPump.UNITS_MGDL;
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
pump = DanaRPump.getInstance();
|
||||
assertEquals(MessageBase.stringFromBuff(createArray(34, (byte) 7), 0, 10), pump.serialNumber);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSettingShippingInfoTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSettingShippingInfo(aapsLogger, danaRPump)
|
||||
danaRPump.units = DanaRPump.UNITS_MGDL
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(MessageBase.stringFromBuff(createArray(34, 7.toByte()), 0, 10), danaRPump.serialNumber)
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingUserOptionsTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingUserOptions packet = new MsgSettingUserOptions();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.units = DanaRPump.UNITS_MGDL;
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(48, (byte) 7));
|
||||
pump = DanaRPump.getInstance();
|
||||
assertEquals((byte) 7 & 255 , pump.lcdOnTimeSec);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
import kotlin.experimental.and
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSettingUserOptionsTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgSettingUserOptions(aapsLogger, danaRPump)
|
||||
danaRPump.units = DanaRPump.UNITS_MGDL
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(48, 7.toByte()))
|
||||
Assert.assertEquals(7, danaRPump.lcdOnTimeSec)
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusBasicTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgStatusBasic packet = new MsgStatusBasic();
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(34, (byte) 7), 0, 3) / 750d, pump.dailyTotalUnits,0);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgStatusBasicTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgStatusBasic(aapsLogger, danaRPump)
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(MessageBase.intFromBuff(createArray(34, 7.toByte()), 0, 3).toDouble() / 750.0, danaRPump.dailyTotalUnits, 0.0)
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusBolusExtendedTest {
|
||||
@Mock
|
||||
Context context;
|
||||
@Test
|
||||
public void runTest() throws Exception{
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
try {
|
||||
AAPSMocker.mockTreatmentService();
|
||||
} catch (Exception e){
|
||||
|
||||
}
|
||||
MsgStatusBolusExtended packet = new MsgStatusBolusExtended();
|
||||
// test message decoding
|
||||
//TODO Find a way to mock treatments plugin
|
||||
// packet.handleMessage(createArray(34, (byte) 7));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
// assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 2, 2)/100d, pump.extendedBolusAmount,0);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgStatusBolusExtendedTest : DanaRTestBase() {
|
||||
|
||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||
@Mock lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||
|
||||
@Test
|
||||
fun runTest() {
|
||||
`when`(activePlugin.activeTreatments).thenReturn(treatmentsPlugin)
|
||||
val packet = MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)
|
||||
// test message decoding
|
||||
val array = ByteArray(100)
|
||||
putByteToArray(array, 0, 1)
|
||||
packet.handleMessage(array)
|
||||
Assert.assertEquals(true, danaRPump.isExtendedInProgress)
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusProfileTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgStatusProfile packet = new MsgStatusProfile();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.units = DanaRPump.UNITS_MGDL;
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 0, 2), pump.currentCIR,0);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgStatusProfileTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgStatusProfile(aapsLogger, danaRPump)
|
||||
danaRPump.units = DanaRPump.UNITS_MGDL
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(MessageBase.intFromBuff(createArray(10, 7.toByte()), 0, 2), danaRPump.currentCIR)
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/31/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusTempBasalTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgStatusTempBasal packet = new MsgStatusTempBasal();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
// test message decoding
|
||||
// Calling context.getResources() before super.onCreate() returns nullPointerException
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgStatusTempBasalTest : DanaRTestBase() {
|
||||
|
||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||
@Mock lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||
|
||||
@Test fun runTest() {
|
||||
`when`(activePlugin.activeTreatments).thenReturn(treatmentsPlugin)
|
||||
val packet = MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin)
|
||||
// test message decoding
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
Assert.assertEquals(true, danaRPump.isTempBasalInProgress)
|
||||
// passing an bigger number
|
||||
packet.handleMessage(createArray(34, 2.toByte()))
|
||||
Assert.assertEquals(false, danaRPump.isTempBasalInProgress)
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgStatus packet = new MsgStatus();
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(34, (byte) 7), 0, 3) / 750d, pump.dailyTotalUnits,0);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgStatusTest : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgStatus(aapsLogger, danaRPump)
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(MessageBase.intFromBuff(createArray(34, 7.toByte()), 0, 3).toDouble() / 750.0, danaRPump.dailyTotalUnits, 0.0)
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by mike on 20.11.2017.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class})
|
||||
public class MsgSetAPSTempBasalStart_v2Test extends MsgSetAPSTempBasalStart_v2 {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
|
||||
// under 100% should last 30 min
|
||||
setParams(0);
|
||||
assertEquals(0, intFromBuff(buffer, 0, 2));
|
||||
assertEquals(PARAM30MIN, intFromBuff(buffer, 2, 1));
|
||||
resetBuffer();
|
||||
// over 100% should last 15 min
|
||||
setParams(150);
|
||||
assertEquals(150, intFromBuff(buffer, 0, 2));
|
||||
assertEquals(PARAM15MIN, intFromBuff(buffer, 2, 1));
|
||||
resetBuffer();
|
||||
// test low hard limit
|
||||
setParams(-1);
|
||||
assertEquals(0, intFromBuff(buffer, 0, 2));
|
||||
assertEquals(PARAM30MIN, intFromBuff(buffer, 2, 1));
|
||||
resetBuffer();
|
||||
// test high hard limit
|
||||
setParams(550);
|
||||
assertEquals(500, intFromBuff(buffer, 0, 2));
|
||||
assertEquals(PARAM15MIN, intFromBuff(buffer, 2, 1));
|
||||
resetBuffer();
|
||||
// test setting 15 min
|
||||
setParams(50, true, false);
|
||||
assertEquals(50, intFromBuff(buffer, 0, 2));
|
||||
assertEquals(PARAM15MIN, intFromBuff(buffer, 2, 1));
|
||||
resetBuffer();
|
||||
// test setting 30 min
|
||||
setParams(50, false, true);
|
||||
assertEquals(50, intFromBuff(buffer, 0, 2));
|
||||
assertEquals(PARAM30MIN, intFromBuff(buffer, 2, 1));
|
||||
resetBuffer();
|
||||
// over 200% set always 15 min
|
||||
setParams(250, false, true);
|
||||
assertEquals(250, intFromBuff(buffer, 0, 2));
|
||||
assertEquals(PARAM15MIN, intFromBuff(buffer, 2, 1));
|
||||
resetBuffer();
|
||||
// test low hard limit
|
||||
setParams(-1, false, true);
|
||||
assertEquals(0, intFromBuff(buffer, 0, 2));
|
||||
assertEquals(PARAM30MIN, intFromBuff(buffer, 2, 1));
|
||||
resetBuffer();
|
||||
// test high hard limit
|
||||
setParams(550, false, true);
|
||||
assertEquals(500, intFromBuff(buffer, 0, 2));
|
||||
assertEquals(PARAM15MIN, intFromBuff(buffer, 2, 1));
|
||||
resetBuffer();
|
||||
|
||||
// test message decoding
|
||||
handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0});
|
||||
assertEquals(true, failed);
|
||||
handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1});
|
||||
assertEquals(false, failed);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase.intFromBuff
|
||||
import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet_APS_Basal_Set_Temporary_Basal.Companion.PARAM30MIN
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSetAPSTempBasalStart_v2Test : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
|
||||
// test low hard limit
|
||||
var packet = MsgSetAPSTempBasalStart_v2(aapsLogger, -1, true, false)
|
||||
Assert.assertEquals(0, intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(packet.PARAM15MIN, intFromBuff(packet.buffer, 2, 1))
|
||||
// test high hard limit
|
||||
packet = MsgSetAPSTempBasalStart_v2(aapsLogger, 550, true, false)
|
||||
Assert.assertEquals(500, intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(packet.PARAM15MIN, intFromBuff(packet.buffer, 2, 1))
|
||||
// test setting 15 min
|
||||
packet = MsgSetAPSTempBasalStart_v2(aapsLogger, 50, true, false)
|
||||
Assert.assertEquals(50, intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(packet.PARAM15MIN, intFromBuff(packet.buffer, 2, 1))
|
||||
// test setting 30 min
|
||||
packet = MsgSetAPSTempBasalStart_v2(aapsLogger, 50, false, true)
|
||||
Assert.assertEquals(50, intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(PARAM30MIN, intFromBuff(packet.buffer, 2, 1))
|
||||
// over 200% set always 15 min
|
||||
packet = MsgSetAPSTempBasalStart_v2(aapsLogger, 250, false, true)
|
||||
Assert.assertEquals(250, intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(packet.PARAM15MIN, intFromBuff(packet.buffer, 2, 1))
|
||||
// test low hard limit
|
||||
packet = MsgSetAPSTempBasalStart_v2(aapsLogger, -1, false, true)
|
||||
Assert.assertEquals(0, intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(PARAM30MIN, intFromBuff(packet.buffer, 2, 1))
|
||||
// test high hard limit
|
||||
packet = MsgSetAPSTempBasalStart_v2(aapsLogger, 550, false, true)
|
||||
Assert.assertEquals(500, intFromBuff(packet.buffer, 0, 2))
|
||||
Assert.assertEquals(packet.PARAM15MIN, intFromBuff(packet.buffer, 2, 1))
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 0.toByte(), 1.toByte()))
|
||||
Assert.assertEquals(false, packet.failed)
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
/**
|
||||
* Created by Rumen Georgiev on 30.10.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetHistoryEntry_v2Test {
|
||||
@Test
|
||||
public void runTest() {
|
||||
|
||||
MsgSetHistoryEntry_v2 initializerTest = new MsgSetHistoryEntry_v2((byte) 1, System.currentTimeMillis(), 1, 0);
|
||||
MsgSetHistoryEntry_v2 packet = new MsgSetHistoryEntry_v2();
|
||||
// test message decoding
|
||||
// != 1 fails
|
||||
packet.handleMessage(createArray(34, (byte) 2));
|
||||
assertEquals(true, packet.failed);
|
||||
// passing an bigger number
|
||||
packet = new MsgSetHistoryEntry_v2();
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
assertEquals(false, packet.failed);
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void mock() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSetHistoryEntry_v2Test : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
var packet = MsgSetHistoryEntry_v2(aapsLogger, 1, System.currentTimeMillis(), 1, 0)
|
||||
// test message decoding
|
||||
// != 1 fails
|
||||
packet.handleMessage(createArray(34, 2.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
// passing an bigger number
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
Assert.assertEquals(false, packet.failed)
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
import static org.junit.Assert.*;
|
||||
/**
|
||||
* Created by Rumen Georgiev on 30.10.2018
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusAPS_v2Test {
|
||||
@Mock
|
||||
Context context;
|
||||
@Test
|
||||
public void runTest() throws Exception{
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
try {
|
||||
AAPSMocker.mockTreatmentService();
|
||||
} catch (Exception e){
|
||||
|
||||
}
|
||||
MsgStatusAPS_v2 packet = new MsgStatusAPS_v2();
|
||||
// test iob
|
||||
//TODO Find a way to mock treatments plugin
|
||||
byte[] testArray = createArray(34, (byte) 7);
|
||||
double iob = MessageBase.intFromBuff(testArray, 0, 2) / 100d;
|
||||
packet.handleMessage(testArray);
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(iob, pump.iob, 0);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgStatusAPS_v2Test : DanaRTestBase() {
|
||||
|
||||
@Test
|
||||
fun runTest() {
|
||||
val packet = MsgStatusAPS_v2(aapsLogger, danaRPump)
|
||||
// test iob
|
||||
//TODO Find a way to mock treatments plugin
|
||||
val testArray = createArray(34, 7.toByte())
|
||||
val iob = MessageBase.intFromBuff(testArray, 0, 2) / 100.0
|
||||
packet.handleMessage(testArray)
|
||||
Assert.assertEquals(iob, danaRPump.iob, 0.0)
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 30.10.2018
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusBolusExtended_v2Test {
|
||||
@Mock
|
||||
Context context;
|
||||
@Test
|
||||
public void runTest() throws Exception{
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
try {
|
||||
AAPSMocker.mockTreatmentService();
|
||||
} catch (Exception e){
|
||||
|
||||
}
|
||||
MsgStatusBolusExtended_v2 packet = new MsgStatusBolusExtended_v2();
|
||||
// test message decoding
|
||||
//TODO Find a way to mock treatments plugin
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 2, 2)/100d, pump.extendedBolusAmount,0);
|
||||
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgStatusBolusExtended_v2Test : DanaRTestBase() {
|
||||
|
||||
@Test
|
||||
fun runTest() {
|
||||
val packet = MsgStatusBolusExtended_v2(aapsLogger, danaRPump)
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 7.toByte()))
|
||||
Assert.assertEquals(MessageBase.intFromBuff(createArray(10, 7.toByte()), 2, 2).toDouble() / 100.0, danaRPump.extendedBolusAmount, 0.0)
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
/**
|
||||
* Created by Rumen Georgiev on 30.10.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusTempBasal_v2Test {
|
||||
@Test
|
||||
public void runTest() {
|
||||
MsgStatusTempBasal_v2 packet = new MsgStatusTempBasal_v2();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
assertEquals(true, pump.isTempBasalInProgress);
|
||||
// passing an bigger number
|
||||
packet = new MsgStatusTempBasal_v2();
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 2));
|
||||
assertEquals(false, pump.isTempBasalInProgress);
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void mock() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgStatusTempBasal_v2Test : DanaRTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = MsgStatusTempBasal_v2(aapsLogger, danaRPump)
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
Assert.assertEquals(true, danaRPump.isTempBasalInProgress)
|
||||
// passing an bigger number
|
||||
packet.handleMessage(createArray(34, 2.toByte()))
|
||||
Assert.assertEquals(false, danaRPump.isTempBasalInProgress)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue