From 130d5874a83c7bf812fe7f2b32fb760684a0f6a5 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 1 Mar 2020 17:10:13 +0100 Subject: [PATCH] DanaRS tests --- ...anaRS_Packet_Bolus_Set_Dual_BolusTest.java | 65 ------------------- .../DanaRS_Packet_Bolus_Set_Dual_BolusTest.kt | 29 +++++++++ ...S_Packet_Bolus_Set_Extended_BolusTest.java | 65 ------------------- ...aRS_Packet_Bolus_Set_Extended_BolusTest.kt | 29 +++++++++ ...t_Bolus_Set_Extended_Bolus_CancelTest.java | 64 ------------------ ...ket_Bolus_Set_Extended_Bolus_CancelTest.kt | 28 ++++++++ ...RS_Packet_Bolus_Set_Initial_BolusTest.java | 62 ------------------ ...naRS_Packet_Bolus_Set_Initial_BolusTest.kt | 26 ++++++++ ...DanaRS_Packet_Etc_Keep_ConnectionTest.java | 46 ------------- .../DanaRS_Packet_Etc_Keep_ConnectionTest.kt | 25 +++++++ ...anaRS_Packet_Etc_Set_History_SaveTest.java | 61 ----------------- .../DanaRS_Packet_Etc_Set_History_SaveTest.kt | 26 ++++++++ ...RS_Packet_General_Delivery_StatusTest.java | 61 ----------------- ...naRS_Packet_General_Delivery_StatusTest.kt | 26 ++++++++ 14 files changed, 189 insertions(+), 424 deletions(-) delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_BolusTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_BolusTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_BolusTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Initial_BolusTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_ConnectionTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Keep_ConnectionTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_SaveTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Etc_Set_History_SaveTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_StatusTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Delivery_StatusTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.java deleted file mode 100644 index 5e16f6ef2e..0000000000 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_Bolus_Set_Dual_BolusTest.java +++ /dev/null @@ -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>> 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