From 1f4f3fb6873557a104f08b7d39fd7202ae09c4f1 Mon Sep 17 00:00:00 2001 From: fabriziocasellato Date: Wed, 20 Nov 2019 16:44:33 +0100 Subject: [PATCH] Added the new MEAL feature to tests --- .../SmsCommunicatorPluginTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.java index bc928ded85..6e83032504 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.java @@ -661,6 +661,35 @@ public class SmsCommunicatorPluginTest { Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.messages.get(0).text); Assert.assertEquals("Pump suspended", smsCommunicatorPlugin.messages.get(1).text); when(pump.isSuspended()).thenReturn(false); + + //BOLUS 1 a + smsCommunicatorPlugin.messages = new ArrayList<>(); + sms = new Sms("1234", "BOLUS 1 a"); + smsCommunicatorPlugin.processSms(sms); + Assert.assertEquals("BOLUS 1 a", smsCommunicatorPlugin.messages.get(0).text); + Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages.get(1).text); + + //BOLUS 1 MEAL + smsCommunicatorPlugin.messages = new ArrayList<>(); + sms = new Sms("1234", "BOLUS 1 MEAL"); + smsCommunicatorPlugin.processSms(sms); + Assert.assertEquals("BOLUS 1 MEAL", smsCommunicatorPlugin.messages.get(0).text); + Assert.assertTrue(smsCommunicatorPlugin.messages.get(1).text.contains("To deliver meal bolus 1.00U reply with code")); + passCode = smsCommunicatorPlugin.messageToConfirm.confirmCode; + smsCommunicatorPlugin.processSms(new Sms("1234", passCode)); + Assert.assertEquals(passCode, smsCommunicatorPlugin.messages.get(2).text); + Assert.assertEquals("Meal Bolus 1.00U delivered successfully\nVirtual Pump", smsCommunicatorPlugin.messages.get(3).text); + + //BOLUS 1 MEAL (Suspended pump) + smsCommunicatorPlugin.lastRemoteBolusTime = 0; + when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump); + when(pump.isSuspended()).thenReturn(true); + smsCommunicatorPlugin.messages = new ArrayList<>(); + sms = new Sms("1234", "BOLUS 1 MEAL"); + smsCommunicatorPlugin.processSms(sms); + Assert.assertEquals("BOLUS 1 MEAL", smsCommunicatorPlugin.messages.get(0).text); + Assert.assertEquals("Pump suspended", smsCommunicatorPlugin.messages.get(1).text); + when(pump.isSuspended()).thenReturn(false); } @Test