From b7305f156f7548c16cdc1351426bf9353429df91 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 12 Mar 2019 19:14:15 +0100 Subject: [PATCH] SmsActionTest --- .../smsCommunicator/SmsActionTest.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsActionTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsActionTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsActionTest.java new file mode 100644 index 0000000000..f4d61e56eb --- /dev/null +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsActionTest.java @@ -0,0 +1,90 @@ +package info.nightscout.androidaps.plugins.general.smsCommunicator; + +import android.telephony.SmsMessage; + +import org.junit.Assert; +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.R; + +import static org.powermock.api.mockito.PowerMockito.mock; +import static org.powermock.api.mockito.PowerMockito.when; + +@RunWith(PowerMockRunner.class) + +public class SmsActionTest { + String result = ""; + + @Test + public void doTests() { + + SmsAction smsAction = new SmsAction() { + @Override + public void run() { + result = "A"; + } + }; + smsAction.run(); + Assert.assertEquals(result, "A"); + + smsAction = new SmsAction(1d) { + @Override + public void run() { + result = "B"; + } + }; + smsAction.run(); + Assert.assertEquals(result, "B"); + Assert.assertEquals(smsAction.aDouble, 1d, 0.000001d); + + smsAction = new SmsAction(1d, 2) { + @Override + public void run() { + result = "C"; + } + }; + smsAction.run(); + Assert.assertEquals(result, "C"); + Assert.assertEquals(smsAction.aDouble, 1d, 0.000001d); + Assert.assertEquals(smsAction.secondInteger.intValue(), 2); + + smsAction = new SmsAction("aString", 3) { + @Override + public void run() { + result = "D"; + } + }; + smsAction.run(); + Assert.assertEquals(result, "D"); + Assert.assertEquals(smsAction.aString, "aString"); + Assert.assertEquals(smsAction.secondInteger.intValue(), 3); + + smsAction = new SmsAction(4) { + @Override + public void run() { + result = "E"; + } + }; + smsAction.run(); + Assert.assertEquals(result, "E"); + Assert.assertEquals(smsAction.anInteger.intValue(), 4); + + smsAction = new SmsAction(5, 6) { + @Override + public void run() { + result = "F"; + } + }; + smsAction.run(); + Assert.assertEquals(result, "F"); + Assert.assertEquals(smsAction.anInteger.intValue(), 5); + Assert.assertEquals(smsAction.secondInteger.intValue(), 6); + } + +}