ExtendedBolusExtensionKtTest

This commit is contained in:
Milos Kozak 2023-09-03 10:31:47 +02:00
parent 1bc34a37f6
commit cbe0e0cb7f

View file

@ -2,6 +2,7 @@ package info.nightscout.core.extensions
import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.insulin.InsulinLyumjevPlugin
import info.nightscout.interfaces.aps.AutosensResult
import info.nightscout.interfaces.aps.SMBDefaults
@ -72,4 +73,14 @@ class ExtendedBolusExtensionKtTest : TestBaseWithProfile() {
Mockito.`when`(dateUtil.now()).thenReturn(now + T.hours(2).msecs())
Assertions.assertFalse(bolus.isInProgress(dateUtil))
}
@Test
fun toTemporaryBasal() {
val bolus = ExtendedBolus(timestamp = now - 1, amount = 1.0, duration = T.hours(1).msecs())
val tbr = bolus.toTemporaryBasal(validProfile)
Assertions.assertEquals(bolus.timestamp, tbr.timestamp)
Assertions.assertEquals(bolus.duration, tbr.duration)
Assertions.assertEquals(bolus.rate + validProfile.getBasal(now), tbr.rate)
Assertions.assertEquals(TemporaryBasal.Type.FAKE_EXTENDED, tbr.type)
}
}