DanaRS tests
This commit is contained in:
parent
394ba420aa
commit
130d5874a8
14 changed files with 189 additions and 424 deletions
|
@ -1,65 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.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.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Set_Dual_BolusTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Set_Dual_Bolus packet = new DanaRS_Packet_Bolus_Set_Dual_Bolus(0d, 0d, 1);
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(0, testparams[0]);
|
||||
assertEquals(1, testparams[4]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
// DanaRPump testPump = DanaRPump.getInstance();
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__SET_DUAL_BOLUS", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
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,29 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest()
|
||||
class DanaRS_Packet_Bolus_Set_Dual_BolusTest : DanaRSTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = DanaRS_Packet_Bolus_Set_Dual_Bolus(aapsLogger, 0.0, 0.0, 1)
|
||||
// test params
|
||||
val testparams = packet.requestParams
|
||||
Assert.assertEquals(0.toByte(), testparams[0])
|
||||
Assert.assertEquals(1.toByte(), testparams[4])
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 0.toByte()))
|
||||
// DanaRPump testPump = DanaRPump.getInstance();
|
||||
Assert.assertEquals(false, packet.failed)
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
Assert.assertEquals("BOLUS__SET_DUAL_BOLUS", packet.friendlyName)
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.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.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Set_Extended_BolusTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Set_Extended_Bolus packet = new DanaRS_Packet_Bolus_Set_Extended_Bolus(1d, 1);
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(100, testparams[0]);
|
||||
assertEquals(1, testparams[2]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
// DanaRPump testPump = DanaRPump.getInstance();
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__SET_EXTENDED_BOLUS", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
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,29 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest()
|
||||
class DanaRS_Packet_Bolus_Set_Extended_BolusTest : DanaRSTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus(aapsLogger, 1.0, 1)
|
||||
// test params
|
||||
val testparams = packet.requestParams
|
||||
Assert.assertEquals(100.toByte(), testparams[0])
|
||||
Assert.assertEquals(1.toByte(), testparams[2])
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 0.toByte()))
|
||||
// DanaRPump testPump = DanaRPump.getInstance();
|
||||
Assert.assertEquals(false, packet.failed)
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
Assert.assertEquals("BOLUS__SET_EXTENDED_BOLUS", packet.friendlyName)
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.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.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel packet = new DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
// DanaRPump testPump = DanaRPump.getInstance();
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__SET_EXTENDED_BOLUS_CANCEL", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
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,28 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest()
|
||||
class DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest : DanaRSTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(aapsLogger)
|
||||
// test params
|
||||
val testparams = packet.requestParams
|
||||
Assert.assertEquals(null, packet.requestParams)
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 0.toByte()))
|
||||
// DanaRPump testPump = DanaRPump.getInstance();
|
||||
Assert.assertEquals(false, packet.failed)
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
Assert.assertEquals("BOLUS__SET_EXTENDED_BOLUS_CANCEL", packet.friendlyName)
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.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.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Set_Initial_BolusTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Set_Initial_Bolus packet = new DanaRS_Packet_Bolus_Set_Initial_Bolus(0d, 0d, 0d, 100d);
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(0, testparams[0]);
|
||||
assertEquals(1, testparams[6]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__SET_BOLUS_RATE", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
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,26 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest()
|
||||
class DanaRS_Packet_Bolus_Set_Initial_BolusTest : DanaRSTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = DanaRS_Packet_Bolus_Set_Initial_Bolus(aapsLogger, 0, 0, 0, 100)
|
||||
// test params
|
||||
val testparams = packet.requestParams
|
||||
Assert.assertEquals(0.toByte(), testparams[0])
|
||||
Assert.assertEquals(100.toByte(), testparams[6])
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 0.toByte()))
|
||||
Assert.assertEquals(false, packet.failed)
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
Assert.assertEquals("BOLUS__SET_BOLUS_RATE", packet.friendlyName)
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.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.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Etc_Keep_ConnectionTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
DanaRS_Packet_Etc_Keep_Connection packet = new DanaRS_Packet_Etc_Keep_Connection();
|
||||
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0});
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(new byte[]{(byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1});
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("ETC__KEEP_CONNECTION", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest()
|
||||
class DanaRS_Packet_Etc_Keep_ConnectionTest : DanaRSTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = DanaRS_Packet_Etc_Keep_Connection(aapsLogger)
|
||||
// test params
|
||||
val testparams = packet.requestParams
|
||||
Assert.assertEquals(null, packet.requestParams)
|
||||
// test message decoding
|
||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||
Assert.assertEquals(false, packet.failed)
|
||||
packet.handleMessage(byteArrayOf(1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte(), 1.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
Assert.assertEquals("ETC__KEEP_CONNECTION", packet.friendlyName)
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.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.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Etc_Set_History_SaveTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Etc_Set_History_Save packet = new DanaRS_Packet_Etc_Set_History_Save(0,0,0,0,0,0,0,0,2);
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(2, testparams[8]);
|
||||
assertEquals((byte) (2 >>> 8), testparams[9]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("ETC__SET_HISTORY_SAVE", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
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,26 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest()
|
||||
class DanaRS_Packet_Etc_Set_History_SaveTest : DanaRSTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = DanaRS_Packet_Etc_Set_History_Save(aapsLogger, 0, 0, 0, 0, 0, 0, 0, 0, 2)
|
||||
// test params
|
||||
val testparams = packet.requestParams
|
||||
Assert.assertEquals(2.toByte(), testparams[8])
|
||||
Assert.assertEquals((2 ushr 8).toByte(), testparams[9])
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, 0.toByte()))
|
||||
Assert.assertEquals(false, packet.failed)
|
||||
packet.handleMessage(createArray(34, 1.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
Assert.assertEquals("ETC__SET_HISTORY_SAVE", packet.friendlyName)
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.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.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_General_Delivery_StatusTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_General_Delivery_Status packet = new DanaRS_Packet_General_Delivery_Status();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
// everything ok :)
|
||||
packet.handleMessage(createArray(15, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(15, (byte) 161));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("REVIEW__DELIVERY_STATUS", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
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,26 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest()
|
||||
class DanaRS_Packet_General_Delivery_StatusTest : DanaRSTestBase() {
|
||||
|
||||
@Test fun runTest() {
|
||||
val packet = DanaRS_Packet_General_Delivery_Status(aapsLogger)
|
||||
// test params
|
||||
val testparams = packet.requestParams
|
||||
Assert.assertEquals(null, packet.requestParams)
|
||||
// test message decoding
|
||||
// everything ok :)
|
||||
packet.handleMessage(createArray(15, 0.toByte()))
|
||||
Assert.assertEquals(false, packet.failed)
|
||||
packet.handleMessage(createArray(15, 161.toByte()))
|
||||
Assert.assertEquals(true, packet.failed)
|
||||
Assert.assertEquals("REVIEW__DELIVERY_STATUS", packet.friendlyName)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue