move RS tests
This commit is contained in:
parent
6022bf8fb2
commit
738964faef
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,7 +2,7 @@
|
||||||
.gradle
|
.gradle
|
||||||
/local.properties
|
/local.properties
|
||||||
.DS_Store
|
.DS_Store
|
||||||
app/jacoco.exec
|
*/jacoco.exec
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
*.apk
|
*.apk
|
||||||
|
|
|
@ -3,19 +3,18 @@ package info.nightscout.androidaps
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.interfaces.ProfileStore
|
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch
|
import info.nightscout.androidaps.db.ProfileSwitch
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.db.Treatment
|
import info.nightscout.androidaps.db.Treatment
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.ConfigInterface
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileStore
|
||||||
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
|
||||||
import info.nightscout.androidaps.utils.rx.TestAapsSchedulers
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -23,13 +22,15 @@ import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
|
||||||
@PrepareForTest(FabricPrivacy::class)
|
@PrepareForTest(FabricPrivacy::class)
|
||||||
open class TestBaseWithProfile : TestBase() {
|
open class TestBaseWithProfile : TestBase() {
|
||||||
|
|
||||||
@Mock lateinit var activePluginProvider: ActivePluginProvider
|
@Mock lateinit var activePluginProvider: ActivePluginProvider
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
@Mock lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Mock lateinit var treatmentsPlugin: TreatmentsInterface
|
||||||
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Mock lateinit var profileFunction: ProfileFunction
|
@Mock lateinit var profileFunction: ProfileFunction
|
||||||
@Mock lateinit var defaultValueHelper: DefaultValueHelper
|
@Mock lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
@Mock lateinit var dateUtil: DateUtil
|
@Mock lateinit var dateUtil: DateUtil
|
||||||
|
@Mock lateinit var configInterface: ConfigInterface
|
||||||
|
|
||||||
val rxBus = RxBusWrapper(aapsSchedulers)
|
val rxBus = RxBusWrapper(aapsSchedulers)
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ open class TestBaseWithProfile : TestBase() {
|
||||||
it.resourceHelper = resourceHelper
|
it.resourceHelper = resourceHelper
|
||||||
it.rxBus = rxBus
|
it.rxBus = rxBus
|
||||||
it.fabricPrivacy = fabricPrivacy
|
it.fabricPrivacy = fabricPrivacy
|
||||||
it.configInterface = Config()
|
it.configInterface = configInterface
|
||||||
}
|
}
|
||||||
if (it is ProfileSwitch) {
|
if (it is ProfileSwitch) {
|
||||||
it.treatmentsPlugin = treatmentsPlugin
|
it.treatmentsPlugin = treatmentsPlugin
|
||||||
|
@ -61,7 +62,7 @@ open class TestBaseWithProfile : TestBase() {
|
||||||
|
|
||||||
private lateinit var validProfileJSON: String
|
private lateinit var validProfileJSON: String
|
||||||
lateinit var validProfile: Profile
|
lateinit var validProfile: Profile
|
||||||
val TESTPROFILENAME = "someProfile"
|
@Suppress("PropertyName") val TESTPROFILENAME = "someProfile"
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun prepareMock() {
|
fun prepareMock() {
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package info.nightscout.androidaps.dana
|
|
||||||
|
|
||||||
import org.junit.Test
|
|
||||||
|
|
||||||
import org.junit.Assert.*
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Example local unit test, which will execute on the development machine (host).
|
|
||||||
*
|
|
||||||
* See [testing documentation](http://d.android.com/tools/testing).
|
|
||||||
*/
|
|
||||||
class ExampleUnitTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun addition_isCorrect() {
|
|
||||||
assertEquals(4, 2 + 2)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,7 @@ android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 24
|
minSdkVersion 26
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
@ -35,6 +35,12 @@ android {
|
||||||
ext.enableCrashlytics = false
|
ext.enableCrashlytics = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
flavorDimensions "standard"
|
||||||
|
productFlavors {
|
||||||
|
full {
|
||||||
|
dimension "standard"
|
||||||
|
}
|
||||||
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
|
40
danars/src/test/java/info/nightscout/androidaps/TestBase.kt
Normal file
40
danars/src/test/java/info/nightscout/androidaps/TestBase.kt
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package info.nightscout.androidaps
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLoggerTest
|
||||||
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
|
import info.nightscout.androidaps.utils.rx.TestAapsSchedulers
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.mockito.Mockito
|
||||||
|
import org.mockito.junit.MockitoJUnit
|
||||||
|
import org.mockito.junit.MockitoRule
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@Suppress("SpellCheckingInspection")
|
||||||
|
open class TestBase {
|
||||||
|
|
||||||
|
val aapsLogger = AAPSLoggerTest()
|
||||||
|
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
|
||||||
|
|
||||||
|
// Add a JUnit rule that will setup the @Mock annotated vars and log.
|
||||||
|
// Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method.
|
||||||
|
@get:Rule
|
||||||
|
val mockitoRule: MockitoRule = MockitoJUnit.rule()
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setupLocale() {
|
||||||
|
Locale.setDefault(Locale.ENGLISH)
|
||||||
|
System.setProperty("disableFirebase", "true")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workaround for Kotlin nullability.
|
||||||
|
// https://medium.com/@elye.project/befriending-kotlin-and-mockito-1c2e7b0ef791
|
||||||
|
// https://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin
|
||||||
|
fun <T> anyObject(): T {
|
||||||
|
Mockito.any<T>()
|
||||||
|
return uninitialized()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("Unchecked_Cast")
|
||||||
|
fun <T> uninitialized(): T = null as T
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
package info.nightscout.androidaps
|
||||||
|
|
||||||
|
import dagger.android.AndroidInjector
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.data.Profile
|
||||||
|
import info.nightscout.androidaps.db.ProfileSwitch
|
||||||
|
import info.nightscout.androidaps.db.Treatment
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.ConfigInterface
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileStore
|
||||||
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import org.json.JSONObject
|
||||||
|
import org.junit.Before
|
||||||
|
import org.mockito.Mock
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
|
||||||
|
@PrepareForTest(FabricPrivacy::class)
|
||||||
|
open class TestBaseWithProfile : TestBase() {
|
||||||
|
|
||||||
|
@Mock lateinit var activePluginProvider: ActivePluginProvider
|
||||||
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Mock lateinit var treatmentsPlugin: TreatmentsInterface
|
||||||
|
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@Mock lateinit var profileFunction: ProfileFunction
|
||||||
|
@Mock lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
|
@Mock lateinit var dateUtil: DateUtil
|
||||||
|
@Mock lateinit var configInterface: ConfigInterface
|
||||||
|
|
||||||
|
val rxBus = RxBusWrapper(aapsSchedulers)
|
||||||
|
|
||||||
|
private val profileInjector = HasAndroidInjector {
|
||||||
|
AndroidInjector {
|
||||||
|
if (it is Profile) {
|
||||||
|
it.aapsLogger = aapsLogger
|
||||||
|
it.activePlugin = activePluginProvider
|
||||||
|
it.resourceHelper = resourceHelper
|
||||||
|
it.rxBus = rxBus
|
||||||
|
it.fabricPrivacy = fabricPrivacy
|
||||||
|
it.configInterface = configInterface
|
||||||
|
}
|
||||||
|
if (it is ProfileSwitch) {
|
||||||
|
it.treatmentsPlugin = treatmentsPlugin
|
||||||
|
it.aapsLogger = aapsLogger
|
||||||
|
it.rxBus = rxBus
|
||||||
|
it.resourceHelper = resourceHelper
|
||||||
|
it.dateUtil = dateUtil
|
||||||
|
}
|
||||||
|
if (it is Treatment) {
|
||||||
|
it.activePlugin = activePluginProvider
|
||||||
|
it.profileFunction = profileFunction
|
||||||
|
it.defaultValueHelper = defaultValueHelper
|
||||||
|
it.resourceHelper = resourceHelper
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private lateinit var validProfileJSON: String
|
||||||
|
lateinit var validProfile: Profile
|
||||||
|
private val testProfileName = "someProfile"
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun prepareMock() {
|
||||||
|
@Suppress("SpellCheckingInspection")
|
||||||
|
validProfileJSON = "{\"dia\":\"3\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"100\"},{\"time\":\"2:00\",\"value\":\"110\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4\"}],\"target_high\":[{\"time\":\"00:00\",\"value\":\"5\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}"
|
||||||
|
validProfile = Profile(profileInjector, JSONObject(validProfileJSON), Constants.MGDL)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getValidProfileStore(): ProfileStore {
|
||||||
|
val json = JSONObject()
|
||||||
|
val store = JSONObject()
|
||||||
|
store.put(testProfileName, JSONObject(validProfileJSON))
|
||||||
|
json.put("defaultProfile", testProfileName)
|
||||||
|
json.put("store", store)
|
||||||
|
return ProfileStore(profileInjector, json)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,11 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS
|
package info.nightscout.androidaps.plugins.pump.danars
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
|
||||||
import info.nightscout.androidaps.Config
|
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.R
|
|
||||||
import info.nightscout.androidaps.danars.DanaRSPlugin
|
import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||||
import info.nightscout.androidaps.danars.comm.DanaRSTestBase
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
|
import info.nightscout.androidaps.danars.R
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
@ -24,6 +22,7 @@ import org.mockito.Mockito
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
@Suppress("SpellCheckingInspection")
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(ConstraintChecker::class, RxBusWrapper::class, DetailedBolusInfoStorage::class)
|
@PrepareForTest(ConstraintChecker::class, RxBusWrapper::class, DetailedBolusInfoStorage::class)
|
||||||
class DanaRSPluginTest : DanaRSTestBase() {
|
class DanaRSPluginTest : DanaRSTestBase() {
|
||||||
|
@ -65,6 +64,6 @@ class DanaRSPluginTest : DanaRSTestBase() {
|
||||||
Mockito.`when`(resourceHelper.gs(eq(R.string.limitingbasalratio), anyObject(), anyObject())).thenReturn("limitingbasalratio")
|
Mockito.`when`(resourceHelper.gs(eq(R.string.limitingbasalratio), anyObject(), anyObject())).thenReturn("limitingbasalratio")
|
||||||
Mockito.`when`(resourceHelper.gs(eq(R.string.limitingpercentrate), anyObject(), anyObject())).thenReturn("limitingpercentrate")
|
Mockito.`when`(resourceHelper.gs(eq(R.string.limitingpercentrate), anyObject(), anyObject())).thenReturn("limitingpercentrate")
|
||||||
|
|
||||||
danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
|
danaRSPlugin = DanaRSPlugin({ AndroidInjector { } }, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,11 @@
|
||||||
package info.nightscout.androidaps.danars.comm
|
package info.nightscout.androidaps.danars
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.TestBaseWithProfile
|
import info.nightscout.androidaps.TestBaseWithProfile
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal
|
|
||||||
import info.nightscout.androidaps.dana.DanaPump
|
import info.nightscout.androidaps.dana.DanaPump
|
||||||
|
import info.nightscout.androidaps.danars.comm.DanaRS_Packet
|
||||||
|
import info.nightscout.androidaps.db.TemporaryBasal
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -42,6 +43,7 @@ open class DanaRSTestBase : TestBaseWithProfile() {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
fun putIntToArray(array: ByteArray, position: Int, value: Int): ByteArray {
|
fun putIntToArray(array: ByteArray, position: Int, value: Int): ByteArray {
|
||||||
array[DanaRS_Packet.DATA_START + position] = (value and 0xFF).toByte()
|
array[DanaRS_Packet.DATA_START + position] = (value and 0xFF).toByte()
|
||||||
array[DanaRS_Packet.DATA_START + position + 1] = ((value and 0xFF00) shr 8).toByte()
|
array[DanaRS_Packet.DATA_START + position + 1] = ((value and 0xFF00) shr 8).toByte()
|
||||||
|
@ -55,6 +57,6 @@ open class DanaRSTestBase : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
danaPump = info.nightscout.androidaps.dana.DanaPump(aapsLogger, sp, injector)
|
danaPump = DanaPump(aapsLogger, sp, injector)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Basal_Set_Temporary_BasalTest : DanaRSTestBase() {
|
class DanaRSPacketBasalSetTemporaryBasalTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface
|
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
@ -12,7 +13,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_History_AlarmTest : DanaRSTestBase() {
|
class DanaRSPacketHistoryAlarmTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var databaseHelper: DatabaseHelperInterface
|
@Mock lateinit var databaseHelper: DatabaseHelperInterface
|
||||||
@Mock lateinit var nsUpload: NSUpload
|
@Mock lateinit var nsUpload: NSUpload
|
||||||
|
@ -48,7 +49,8 @@ class DanaRS_Packet_History_AlarmTest : DanaRSTestBase() {
|
||||||
|
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_ALARM, packet.danaRHistoryRecord.recordCode)
|
Assert.assertEquals(info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_ALARM, packet.danaRHistoryRecord.recordCode)
|
||||||
Assert.assertEquals(Date(119, 1, 4, 20, 11, 35).time, packet.danaRHistoryRecord.recordDate)
|
val date = Calendar.getInstance().also { it.set(2019, 2, 4, 20, 11, 35) }
|
||||||
|
Assert.assertEquals(date.timeInMillis, packet.danaRHistoryRecord.recordDate)
|
||||||
Assert.assertEquals("Occlusion", packet.danaRHistoryRecord.recordAlarm)
|
Assert.assertEquals("Occlusion", packet.danaRHistoryRecord.recordAlarm)
|
||||||
Assert.assertEquals(3.56, packet.danaRHistoryRecord.recordValue, 0.01)
|
Assert.assertEquals(3.56, packet.danaRHistoryRecord.recordValue, 0.01)
|
||||||
Assert.assertEquals("REVIEW__ALARM", packet.friendlyName)
|
Assert.assertEquals("REVIEW__ALARM", packet.friendlyName)
|
|
@ -2,10 +2,11 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import info.nightscout.androidaps.db.Treatment
|
import info.nightscout.androidaps.db.Treatment
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.danars.DanaRSPlugin
|
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
@ -18,9 +19,8 @@ import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(RxBusWrapper::class, DanaRSPlugin::class)
|
@PrepareForTest(RxBusWrapper::class, DanaRSPlugin::class)
|
||||||
class DanaRS_Packet_Notify_Delivery_CompleteTest : DanaRSTestBase() {
|
class DanaRSPacketNotifyDeliveryCompleteTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var danaRSPlugin: DanaRSPlugin
|
|
||||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Option_Set_User_OptionTest : DanaRSTestBase() {
|
class DanaRSPacketOptionSetUserOptionTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -0,0 +1,2 @@
|
||||||
|
package info.nightscout.androidaps.danars.comm
|
||||||
|
|
|
@ -2,11 +2,12 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
||||||
import info.nightscout.androidaps.danars.encryption.BleEncryption
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
@ -17,7 +18,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class)
|
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class)
|
||||||
class DanaRSMessageHashTableTest : DanaRSTestBase() {
|
class DanaRsMessageHashTableTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||||
@Mock lateinit var constraintChecker: ConstraintChecker
|
@Mock lateinit var constraintChecker: ConstraintChecker
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketApsBasalSetTemporaryBasalTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -20,6 +19,7 @@ class DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest : DanaRSTestBase() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
|
|
||||||
// under 100% should last 30 min
|
// under 100% should last 30 min
|
|
@ -3,10 +3,11 @@ package info.nightscout.androidaps.danars.comm
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
||||||
import info.nightscout.androidaps.danars.DanaRSPlugin
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -18,7 +19,7 @@ import java.util.*
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(RxBusWrapper::class, DetailedBolusInfoStorage::class, DanaRSPlugin::class)
|
@PrepareForTest(RxBusWrapper::class, DetailedBolusInfoStorage::class, DanaRSPlugin::class)
|
||||||
class DanaRS_Packet_APS_History_EventsTest : DanaRSTestBase() {
|
class DanaRsPacketApsHistoryEventsTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var context: Context
|
@Mock lateinit var context: Context
|
||||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
|
@ -2,16 +2,15 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketApsSetEventHistoryTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_APS_Set_Event_HistoryTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -28,22 +27,22 @@ class DanaRS_Packet_APS_Set_Event_HistoryTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() { // test for negative carbs
|
@Test fun runTest() { // test for negative carbs
|
||||||
val now = DateUtil.now()
|
val now = DateUtil.now()
|
||||||
var historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, -1, 0)
|
var historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, -1, 0)
|
||||||
var testparams = historyTest.requestParams
|
var testParams = historyTest.requestParams
|
||||||
Assert.assertEquals(0.toByte(), testparams[8])
|
Assert.assertEquals(0.toByte(), testParams[8])
|
||||||
// 5g carbs
|
// 5g carbs
|
||||||
historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 5, 0)
|
historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 5, 0)
|
||||||
testparams = historyTest.requestParams
|
testParams = historyTest.requestParams
|
||||||
Assert.assertEquals(5.toByte(), testparams[8])
|
Assert.assertEquals(5.toByte(), testParams[8])
|
||||||
// 150g carbs
|
// 150g carbs
|
||||||
historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 150, 0)
|
historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 150, 0)
|
||||||
testparams = historyTest.requestParams
|
testParams = historyTest.requestParams
|
||||||
Assert.assertEquals(150.toByte(), testparams[8])
|
Assert.assertEquals(150.toByte(), testParams[8])
|
||||||
// test message generation
|
// test message generation
|
||||||
historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 5, 0)
|
historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, 5, 0)
|
||||||
testparams = historyTest.requestParams
|
testParams = historyTest.requestParams
|
||||||
Assert.assertEquals(5.toByte(), testparams[8])
|
Assert.assertEquals(5.toByte(), testParams[8])
|
||||||
Assert.assertEquals(11, testparams.size)
|
Assert.assertEquals(11, testParams.size)
|
||||||
Assert.assertEquals(info.nightscout.androidaps.dana.DanaPump.CARBS.toByte(), testparams[0])
|
Assert.assertEquals(info.nightscout.androidaps.dana.DanaPump.CARBS.toByte(), testParams[0])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
historyTest.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
historyTest.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, historyTest.failed)
|
Assert.assertEquals(false, historyTest.failed)
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
@ -11,7 +12,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(RxBusWrapper::class)
|
@PrepareForTest(RxBusWrapper::class)
|
||||||
class DanaRS_Packet_Basal_Get_Basal_RateTest : DanaRSTestBase() {
|
class DanaRsPacketBasalGetBasalRateTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -30,7 +31,7 @@ class DanaRS_Packet_Basal_Get_Basal_RateTest : DanaRSTestBase() {
|
||||||
// rate is 0.01
|
// rate is 0.01
|
||||||
val array = ByteArray(100)
|
val array = ByteArray(100)
|
||||||
putIntToArray(array, 0, (1.0 * 100).toInt())
|
putIntToArray(array, 0, (1.0 * 100).toInt())
|
||||||
putByteToArray(array, 2, (0.05 * 100).toByte())
|
putByteToArray(array, 2, (0.05 * 100).toInt().toByte())
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertEquals(1.0, danaPump.maxBasal, 0.0)
|
Assert.assertEquals(1.0, danaPump.maxBasal, 0.0)
|
||||||
Assert.assertEquals(0.05, danaPump.basalStep, 0.0)
|
Assert.assertEquals(0.05, danaPump.basalStep, 0.0)
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Basal_Get_Profile_Basal_RateTest : DanaRSTestBase() {
|
class DanaRsPacketBasalGetProfileBasalRateTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBasalGetProfileNumberTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Basal_Get_Profile_NumberTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBasalGetTemporaryBasalStateTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBasalSetBasalRateTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Basal_Set_Basal_RateTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBasalSetCancelTemporaryBasalTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Basal_Set_Cancel_Temporary_BasalTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBasalSetProfileBasalRateTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Basal_Set_Profile_Basal_RateTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -23,11 +22,11 @@ class DanaRS_Packet_Basal_Set_Profile_Basal_RateTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(packetInjector, 1, createArray(24, 1.0))
|
val packet = DanaRS_Packet_Basal_Set_Profile_Basal_Rate(packetInjector, 1, createArray(24, 1.0))
|
||||||
// test params
|
// test params
|
||||||
val testparams = packet.requestParams
|
val testParams = packet.requestParams
|
||||||
// is profile 1
|
// is profile 1
|
||||||
Assert.assertEquals(1.toByte(), testparams[0])
|
Assert.assertEquals(1.toByte(), testParams[0])
|
||||||
// is value 100
|
// is value 100
|
||||||
Assert.assertEquals(100.toByte(), testparams[3])
|
Assert.assertEquals(100.toByte(), testParams[3])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assert.assertEquals(false, packet.failed)
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBasalSetProfileNumberTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Basal_Set_Profile_NumberTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -23,9 +22,9 @@ class DanaRS_Packet_Basal_Set_Profile_NumberTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRS_Packet_Basal_Set_Profile_Number(packetInjector, 1)
|
val packet = DanaRS_Packet_Basal_Set_Profile_Number(packetInjector, 1)
|
||||||
// test params
|
// test params
|
||||||
val testparams = packet.requestParams
|
val testParams = packet.requestParams
|
||||||
// is profile 1
|
// is profile 1
|
||||||
Assert.assertEquals(1.toByte(), testparams[0])
|
Assert.assertEquals(1.toByte(), testParams[0])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assert.assertEquals(false, packet.failed)
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBasalSetSuspendOffTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Basal_Set_Suspend_OffTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBasalSetSuspendOnTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Basal_Set_Suspend_OnTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
@ -11,7 +12,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(RxBusWrapper::class)
|
@PrepareForTest(RxBusWrapper::class)
|
||||||
class DanaRS_Packet_Bolus_Get_Bolus_OptionTest : DanaRSTestBase() {
|
class DanaRsPacketBolusGetBolusOptionTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBolusGetCalculationInformationTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Bolus_Get_Calculation_InformationTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBolusGetCarbohydrateCalculationInformationTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -3,13 +3,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.dana.DanaPump
|
import info.nightscout.androidaps.dana.DanaPump
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Bolus_Get_CIR_CF_ArrayTest : DanaRSTestBase() {
|
class DanaRsPacketBolusGetCirCfArrayTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Bolus_Get_Dual_BolusTest : DanaRSTestBase() {
|
class DanaRsPacketBolusGetDualBolusTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBolusGetExtendedBolusStateTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -27,10 +26,10 @@ class DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest : DanaRSTestBase() {
|
||||||
Assert.assertEquals(null, packet.requestParams)
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
var testValue = 0.0
|
var testValue = 0.0
|
||||||
packet.handleMessage(createArray(11, testValue.toByte()))
|
packet.handleMessage(createArray(11, testValue.toInt().toByte()))
|
||||||
Assert.assertEquals(testValue != 0.0, packet.failed)
|
Assert.assertEquals(testValue != 0.0, packet.failed)
|
||||||
testValue = 1.0
|
testValue = 1.0
|
||||||
packet.handleMessage(createArray(11, testValue.toByte()))
|
packet.handleMessage(createArray(11, testValue.toInt().toByte()))
|
||||||
// is extended bolus in progress
|
// is extended bolus in progress
|
||||||
Assert.assertEquals(testValue == 1.0, danaPump.isExtendedInProgress)
|
Assert.assertEquals(testValue == 1.0, danaPump.isExtendedInProgress)
|
||||||
Assert.assertEquals(testValue != 0.0, packet.failed)
|
Assert.assertEquals(testValue != 0.0, packet.failed)
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBolusGetExtendedBolusTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Bolus_Get_Extended_BolusTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -27,11 +26,11 @@ class DanaRS_Packet_Bolus_Get_Extended_BolusTest : DanaRSTestBase() {
|
||||||
Assert.assertEquals(null, packet.requestParams)
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
var testValue = 0.0
|
var testValue = 0.0
|
||||||
packet.handleMessage(createArray(10, testValue.toByte()))
|
packet.handleMessage(createArray(10, testValue.toInt().toByte()))
|
||||||
Assert.assertEquals(testValue != 0.0, packet.failed)
|
Assert.assertEquals(testValue != 0.0, packet.failed)
|
||||||
testValue = 1.0
|
testValue = 1.0
|
||||||
packet.handleMessage(createArray(10, testValue.toByte()))
|
packet.handleMessage(createArray(10, testValue.toInt().toByte()))
|
||||||
// is pump.bolustep set to 1
|
// is pump.bolusStep set to 1
|
||||||
Assert.assertEquals(testValue / 100.0, danaPump.bolusStep, 0.0)
|
Assert.assertEquals(testValue / 100.0, danaPump.bolusStep, 0.0)
|
||||||
Assert.assertEquals(testValue != 0.0, packet.failed)
|
Assert.assertEquals(testValue != 0.0, packet.failed)
|
||||||
Assert.assertEquals("BOLUS__GET_EXTENDED_BOLUS", packet.friendlyName)
|
Assert.assertEquals("BOLUS__GET_EXTENDED_BOLUS", packet.friendlyName)
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest : DanaRSTestBase() {
|
class DanaRsPacketBolusGetExtendedMenuOptionStateTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -24,7 +25,7 @@ class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest : DanaRSTestBase()
|
||||||
Assert.assertEquals(null, packet.requestParams)
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 0.toByte()))
|
packet.handleMessage(createArray(34, 0.toByte()))
|
||||||
// isExtendedinprogres should be false
|
// isExtendedInProgress should be false
|
||||||
Assert.assertEquals(false, danaPump.isExtendedInProgress)
|
Assert.assertEquals(false, danaPump.isExtendedInProgress)
|
||||||
// assertEquals(false, packet.failed);
|
// assertEquals(false, packet.failed);
|
||||||
packet.handleMessage(createArray(34, 1.toByte()))
|
packet.handleMessage(createArray(34, 1.toByte()))
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Bolus_Get_Initial_BolusTest : DanaRSTestBase() {
|
class DanaRsPacketBolusGetInitialBolusTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -23,7 +24,7 @@ class DanaRS_Packet_Bolus_Get_Initial_BolusTest : DanaRSTestBase() {
|
||||||
Assert.assertEquals(null, packet.requestParams)
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 0.toByte()))
|
packet.handleMessage(createArray(34, 0.toByte()))
|
||||||
// should fail only if all the initialbolusses are 0
|
// should fail only if all the initial boluses are 0
|
||||||
Assert.assertEquals(false, !packet.failed)
|
Assert.assertEquals(false, !packet.failed)
|
||||||
packet.handleMessage(createArray(34, 1.toByte()))
|
packet.handleMessage(createArray(34, 1.toByte()))
|
||||||
Assert.assertEquals(true, !packet.failed)
|
Assert.assertEquals(true, !packet.failed)
|
|
@ -2,16 +2,15 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketBolusGetStepBolusInformationTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -41,9 +40,10 @@ class DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest : DanaRSTestBase() {
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertTrue(packet.failed)
|
Assert.assertTrue(packet.failed)
|
||||||
Assert.assertEquals(6.0, danaPump.initialBolusAmount, 0.01)
|
Assert.assertEquals(6.0, danaPump.initialBolusAmount, 0.01)
|
||||||
val lastBolus = Date(danaPump.lastBolusTime)
|
val lastBolus = Calendar.getInstance()
|
||||||
Assert.assertEquals(13, lastBolus.hours)
|
lastBolus.timeInMillis = danaPump.lastBolusTime
|
||||||
Assert.assertEquals(20, lastBolus.minutes)
|
Assert.assertEquals(13, lastBolus.get(Calendar.HOUR_OF_DAY))
|
||||||
|
Assert.assertEquals(20, lastBolus.get(Calendar.MINUTE))
|
||||||
Assert.assertEquals(12.5, danaPump.lastBolusAmount, 0.01)
|
Assert.assertEquals(12.5, danaPump.lastBolusAmount, 0.01)
|
||||||
Assert.assertEquals(25.0, danaPump.maxBolus, 0.01)
|
Assert.assertEquals(25.0, danaPump.maxBolus, 0.01)
|
||||||
Assert.assertEquals(1.0, danaPump.bolusStep, 0.01)
|
Assert.assertEquals(1.0, danaPump.bolusStep, 0.01)
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Bolus_Set_Bolus_OptionTest : DanaRSTestBase() {
|
class DanaRsPacketBolusSetBolusOptionTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -21,9 +22,9 @@ class DanaRS_Packet_Bolus_Set_Bolus_OptionTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRS_Packet_Bolus_Set_Bolus_Option(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
val packet = DanaRS_Packet_Bolus_Set_Bolus_Option(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
// test params
|
// test params
|
||||||
val testparams = packet.requestParams
|
val testParams = packet.requestParams
|
||||||
Assert.assertEquals(0.toByte(), testparams[0])
|
Assert.assertEquals(0.toByte(), testParams[0])
|
||||||
Assert.assertEquals(0.toByte(), testparams[18])
|
Assert.assertEquals(0.toByte(), testParams[18])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 0.toByte()))
|
packet.handleMessage(createArray(34, 0.toByte()))
|
||||||
// DanaRPump testPump = DanaRPump.getInstance();
|
// DanaRPump testPump = DanaRPump.getInstance();
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest : DanaRSTestBase() {
|
class DanaRsPacketBolusSetCirCfArrayTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -21,9 +22,9 @@ class DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRS_Packet_Bolus_Set_CIR_CF_Array(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
val packet = DanaRS_Packet_Bolus_Set_CIR_CF_Array(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
// test params
|
// test params
|
||||||
val testparams = packet.requestParams
|
val testParams = packet.requestParams
|
||||||
Assert.assertEquals(0.toByte(), testparams[0])
|
Assert.assertEquals(0.toByte(), testParams[0])
|
||||||
Assert.assertEquals(0.toByte(), testparams[18])
|
Assert.assertEquals(0.toByte(), testParams[18])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 0.toByte()))
|
packet.handleMessage(createArray(34, 0.toByte()))
|
||||||
// DanaRPump testPump = DanaRPump.getInstance();
|
// DanaRPump testPump = DanaRPump.getInstance();
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Bolus_Set_Dual_BolusTest : DanaRSTestBase() {
|
class DanaRsPacketBolusSetDualBolusTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -21,9 +22,9 @@ class DanaRS_Packet_Bolus_Set_Dual_BolusTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRS_Packet_Bolus_Set_Dual_Bolus(packetInjector, 0.0, 0.0, 1)
|
val packet = DanaRS_Packet_Bolus_Set_Dual_Bolus(packetInjector, 0.0, 0.0, 1)
|
||||||
// test params
|
// test params
|
||||||
val testparams = packet.requestParams
|
val testParams = packet.requestParams
|
||||||
Assert.assertEquals(0.toByte(), testparams[0])
|
Assert.assertEquals(0.toByte(), testParams[0])
|
||||||
Assert.assertEquals(1.toByte(), testparams[4])
|
Assert.assertEquals(1.toByte(), testParams[4])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 0.toByte()))
|
packet.handleMessage(createArray(34, 0.toByte()))
|
||||||
// DanaRPump testPump = DanaRPump.getInstance();
|
// DanaRPump testPump = DanaRPump.getInstance();
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest : DanaRSTestBase() {
|
class DanaRsPacketBolusSetExtendedBolusCancelTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Bolus_Set_Extended_BolusTest : DanaRSTestBase() {
|
class DanaRsPacketBolusSetExtendedBolusTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Bolus_Set_Initial_BolusTest : DanaRSTestBase() {
|
class DanaRsPacketBolusSetInitialBolusTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -21,9 +22,9 @@ class DanaRS_Packet_Bolus_Set_Initial_BolusTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRS_Packet_Bolus_Set_Initial_Bolus(packetInjector, 0, 0, 0, 100)
|
val packet = DanaRS_Packet_Bolus_Set_Initial_Bolus(packetInjector, 0, 0, 0, 100)
|
||||||
// test params
|
// test params
|
||||||
val testparams = packet.requestParams
|
val testParams = packet.requestParams
|
||||||
Assert.assertEquals(0.toByte(), testparams[0])
|
Assert.assertEquals(0.toByte(), testParams[0])
|
||||||
Assert.assertEquals(100.toByte(), testparams[6])
|
Assert.assertEquals(100.toByte(), testParams[6])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 0.toByte()))
|
packet.handleMessage(createArray(34, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assert.assertEquals(false, packet.failed)
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.danars.DanaRSPlugin
|
import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
|
@ -19,7 +20,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class)
|
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class)
|
||||||
class DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest : DanaRSTestBase() {
|
class DanaRsPacketBolusSetStepBolusStartTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var constraintChecker: ConstraintChecker
|
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||||
@Mock lateinit var commandQueue: CommandQueueProvider
|
@Mock lateinit var commandQueue: CommandQueueProvider
|
||||||
|
@ -41,9 +42,9 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(packetInjector)
|
val packet = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(packetInjector)
|
||||||
// test params
|
// test params
|
||||||
val testparams = packet.requestParams
|
val testParams = packet.requestParams
|
||||||
Assert.assertEquals(0.toByte(), testparams[0])
|
Assert.assertEquals(0.toByte(), testParams[0])
|
||||||
Assert.assertEquals(0.toByte(), testparams[2])
|
Assert.assertEquals(0.toByte(), testParams[2])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
packet.handleMessage(byteArrayOf(0.toByte(), 0.toByte(), 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assert.assertEquals(false, packet.failed)
|
|
@ -2,10 +2,11 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import info.nightscout.androidaps.db.Treatment
|
import info.nightscout.androidaps.db.Treatment
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.danars.DanaRSPlugin
|
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
@ -17,7 +18,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(RxBusWrapper::class, DanaRSPlugin::class)
|
@PrepareForTest(RxBusWrapper::class, DanaRSPlugin::class)
|
||||||
class DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest : DanaRSTestBase() {
|
class DanaRsPacketBolusSetStepBolusStopTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||||
|
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Etc_Keep_ConnectionTest : DanaRSTestBase() {
|
class DanaRsPacketEtcKeepConnectionTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketEtcSetHistorySaveTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Etc_Set_History_SaveTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -23,9 +22,9 @@ class DanaRS_Packet_Etc_Set_History_SaveTest : DanaRSTestBase() {
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val packet = DanaRS_Packet_Etc_Set_History_Save(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 2)
|
val packet = DanaRS_Packet_Etc_Set_History_Save(packetInjector, 0, 0, 0, 0, 0, 0, 0, 0, 2)
|
||||||
// test params
|
// test params
|
||||||
val testparams = packet.requestParams
|
val testParams = packet.requestParams
|
||||||
Assert.assertEquals(2.toByte(), testparams[8])
|
Assert.assertEquals(2.toByte(), testParams[8])
|
||||||
Assert.assertEquals((2 ushr 8).toByte(), testparams[9])
|
Assert.assertEquals((2 ushr 8).toByte(), testParams[9])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(34, 0.toByte()))
|
packet.handleMessage(createArray(34, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assert.assertEquals(false, packet.failed)
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketGeneralDeliveryStatusTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_General_Delivery_StatusTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
@ -9,7 +10,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_General_Get_More_InformationTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralGetMoreInformationTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -37,7 +38,7 @@ class DanaRS_Packet_General_Get_More_InformationTest : DanaRSTestBase() {
|
||||||
putIntToArray(array, 5, 150) // extended remaining minutes 150
|
putIntToArray(array, 5, 150) // extended remaining minutes 150
|
||||||
putByteToArray(array, 9, 15) // hours 15
|
putByteToArray(array, 9, 15) // hours 15
|
||||||
putByteToArray(array, 10, 25) // minutes 25
|
putByteToArray(array, 10, 25) // minutes 25
|
||||||
putIntToArray(array, 11, 170) // last bolus manout 1.70
|
putIntToArray(array, 11, 170) // last bolus amount 1.70
|
||||||
|
|
||||||
packet.handleMessage(array)
|
packet.handleMessage(array)
|
||||||
Assert.assertFalse(packet.failed)
|
Assert.assertFalse(packet.failed)
|
||||||
|
@ -45,9 +46,10 @@ class DanaRS_Packet_General_Get_More_InformationTest : DanaRSTestBase() {
|
||||||
Assert.assertEquals(12.5, danaPump.dailyTotalUnits, 0.01)
|
Assert.assertEquals(12.5, danaPump.dailyTotalUnits, 0.01)
|
||||||
Assert.assertTrue(danaPump.isExtendedInProgress)
|
Assert.assertTrue(danaPump.isExtendedInProgress)
|
||||||
Assert.assertEquals(150, danaPump.extendedBolusRemainingMinutes)
|
Assert.assertEquals(150, danaPump.extendedBolusRemainingMinutes)
|
||||||
val lastBolus = Date(danaPump.lastBolusTime)
|
val lastBolus = Calendar.getInstance()
|
||||||
Assert.assertEquals(15, lastBolus.hours)
|
lastBolus.timeInMillis = danaPump.lastBolusTime
|
||||||
Assert.assertEquals(25, lastBolus.minutes)
|
Assert.assertEquals(15, lastBolus.get(Calendar.HOUR_OF_DAY))
|
||||||
|
Assert.assertEquals(25, lastBolus.get(Calendar.MINUTE))
|
||||||
Assert.assertEquals(1.7, danaPump.lastBolusAmount, 0.01)
|
Assert.assertEquals(1.7, danaPump.lastBolusAmount, 0.01)
|
||||||
|
|
||||||
Assert.assertEquals("REVIEW__GET_MORE_INFORMATION", packet.friendlyName)
|
Assert.assertEquals("REVIEW__GET_MORE_INFORMATION", packet.friendlyName)
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_General_Get_PasswordTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralGetPasswordTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -11,7 +12,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(RxBusWrapper::class)
|
@PrepareForTest(RxBusWrapper::class)
|
||||||
class DanaRS_Packet_General_Get_Pump_CheckTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralGetPumpCheckTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_General_Get_Shipping_InformationTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralGetShippingInformationTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_General_Get_Shipping_VerisonTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralGetShippingVerisonTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_General_Get_Today_Delivery_TotalTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralGetTodayDeliveryTotalTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_General_Get_User_Time_Change_FlagTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralGetUserTimeChangeFlagTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_General_Initial_Screen_InformationTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralInitialScreenInformationTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_General_Set_History_Upload_ModeTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralSetHistoryUploadModeTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest : DanaRSTestBase() {
|
class DanaRsPacketGeneralSetUserTimeChangeFlagClearTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_History_All_HistoryTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryAllHistoryTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_History_BasalTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryBasalTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_History_Blood_GlucoseTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryBloodGlucoseTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_History_BolusTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryBolusTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_History_CarbohydrateTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryCarbohydrateTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_History_DailyTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryDailyTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_History_PrimeTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryPrimeTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_History_RefillTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryRefillTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_History_SuspendTest : DanaRSTestBase() {
|
class DanaRsPacketHistorySuspendTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_History_TemporaryTest : DanaRSTestBase() {
|
class DanaRsPacketHistoryTemporaryTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,19 +2,16 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.powermock.api.mockito.PowerMockito
|
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(NSUpload::class)
|
class DanaRsPacketNotifyAlarmTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Notify_AlarmTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
@Mock lateinit var nsUpload: NSUpload
|
@Mock lateinit var nsUpload: NSUpload
|
||||||
|
|
||||||
|
@ -34,7 +31,7 @@ class DanaRS_Packet_Notify_AlarmTest : DanaRSTestBase() {
|
||||||
// test params
|
// test params
|
||||||
Assert.assertEquals(null, packet.requestParams)
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
// test message decoding
|
// test message decoding
|
||||||
// handlemessage testing fails on non-eror byte because of NSUpload not properly mocked
|
// handle message testing fails on non-error byte because of NSUpload not properly mocked
|
||||||
packet.handleMessage(createArray(17, 0x01.toByte()))
|
packet.handleMessage(createArray(17, 0x01.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assert.assertEquals(false, packet.failed)
|
||||||
// no error
|
// no error
|
||||||
|
@ -42,9 +39,4 @@ class DanaRS_Packet_Notify_AlarmTest : DanaRSTestBase() {
|
||||||
Assert.assertEquals(true, packet.failed)
|
Assert.assertEquals(true, packet.failed)
|
||||||
Assert.assertEquals("NOTIFY__ALARM", packet.friendlyName)
|
Assert.assertEquals("NOTIFY__ALARM", packet.friendlyName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
|
||||||
fun mock() {
|
|
||||||
PowerMockito.mockStatic(NSUpload::class.java)
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -3,8 +3,8 @@ package info.nightscout.androidaps.danars.comm
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Config
|
|
||||||
import info.nightscout.androidaps.danars.DanaRSPlugin
|
import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import info.nightscout.androidaps.db.Treatment
|
import info.nightscout.androidaps.db.Treatment
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
|
@ -23,7 +23,7 @@ import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest(ConstraintChecker::class, RxBusWrapper::class, DetailedBolusInfoStorage::class)
|
@PrepareForTest(ConstraintChecker::class, RxBusWrapper::class, DetailedBolusInfoStorage::class)
|
||||||
class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() {
|
class DanaRsPacketNotifyDeliveryRateDisplayTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||||
@Mock lateinit var constraintChecker: ConstraintChecker
|
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||||
|
@ -68,7 +68,7 @@ class DanaRS_Packet_Notify_Delivery_Rate_DisplayTest : DanaRSTestBase() {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun mock() {
|
fun mock() {
|
||||||
danaRSPlugin = DanaRSPlugin(HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
|
danaRSPlugin = DanaRSPlugin(packetInjector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil)
|
||||||
danaPump.bolusingTreatment = Treatment(packetInjector)
|
danaPump.bolusingTreatment = Treatment(packetInjector)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Notify_Missed_Bolus_AlarmTest : DanaRSTestBase() {
|
class DanaRsPacketNotifyMissedBolusAlarmTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -9,7 +10,7 @@ import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Option_Get_Pump_TimeTest : DanaRSTestBase() {
|
class DanaRsPacketOptionGetPumpTimeTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Option_Get_User_OptionTest : DanaRSTestBase() {
|
class DanaRsPacketOptionGetUserOptionTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,14 +2,15 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
|
import org.joda.time.DateTime
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Option_Set_Pump_TimeTest : DanaRSTestBase() {
|
class DanaRsPacketOptionSetPumpTimeTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
||||||
|
@ -17,22 +18,20 @@ class DanaRS_Packet_Option_Set_Pump_TimeTest : DanaRSTestBase() {
|
||||||
it.aapsLogger = aapsLogger
|
it.aapsLogger = aapsLogger
|
||||||
it.dateUtil = dateUtil
|
it.dateUtil = dateUtil
|
||||||
}
|
}
|
||||||
if (it is DanaRS_Packet_Option_Set_Pump_Time) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun runTest() {
|
@Test fun runTest() {
|
||||||
val date = Date()
|
val date = DateTime()
|
||||||
val packet = DanaRS_Packet_Option_Set_Pump_Time(packetInjector, date.time)
|
val packet = DanaRS_Packet_Option_Set_Pump_Time(packetInjector, date.millis)
|
||||||
// test params
|
// test params
|
||||||
val params = packet.requestParams
|
val params = packet.requestParams
|
||||||
Assert.assertEquals((date.year - 100 and 0xff).toByte(), params[0]) // 2019 -> 19
|
Assert.assertEquals((date.year - 2000 and 0xff).toByte(), params[0]) // 2019 -> 19
|
||||||
Assert.assertEquals((date.month + 1 and 0xff).toByte(), params[1])
|
Assert.assertEquals((date.monthOfYear and 0xff).toByte(), params[1])
|
||||||
Assert.assertEquals((date.date and 0xff).toByte(), params[2])
|
Assert.assertEquals((date.dayOfMonth and 0xff).toByte(), params[2])
|
||||||
Assert.assertEquals((date.hours and 0xff).toByte(), params[3])
|
Assert.assertEquals((date.hourOfDay and 0xff).toByte(), params[3])
|
||||||
Assert.assertEquals((date.minutes and 0xff).toByte(), params[4])
|
Assert.assertEquals((date.minuteOfHour and 0xff).toByte(), params[4])
|
||||||
Assert.assertEquals((date.seconds and 0xff).toByte(), params[5])
|
Assert.assertEquals((date.secondOfMinute and 0xff).toByte(), params[5])
|
||||||
// test message decoding
|
// test message decoding
|
||||||
packet.handleMessage(createArray(3, 0.toByte()))
|
packet.handleMessage(createArray(3, 0.toByte()))
|
||||||
Assert.assertEquals(false, packet.failed)
|
Assert.assertEquals(false, packet.failed)
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
@PrepareForTest()
|
class DanaRsPacketReviewBolusAvgTest : DanaRSTestBase() {
|
||||||
class DanaRS_Packet_Review_Bolus_AvgTest : DanaRSTestBase() {
|
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
|
@ -2,13 +2,14 @@ package info.nightscout.androidaps.danars.comm
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.powermock.modules.junit4.PowerMockRunner
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
@RunWith(PowerMockRunner::class)
|
@RunWith(PowerMockRunner::class)
|
||||||
class DanaRS_Packet_Review_Get_Pump_Dec_RatioTest : DanaRSTestBase() {
|
class DanaRsPacketReviewGetPumpDecRatioTest : DanaRSTestBase() {
|
||||||
|
|
||||||
private val packetInjector = HasAndroidInjector {
|
private val packetInjector = HasAndroidInjector {
|
||||||
AndroidInjector {
|
AndroidInjector {
|
Loading…
Reference in a new issue