parent
0731827b38
commit
b2aa328e67
1 changed files with 11 additions and 11 deletions
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.core.extensions
|
||||
|
||||
import app.aaps.shared.tests.TestBaseWithProfile
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import info.nightscout.database.entities.Bolus
|
||||
import info.nightscout.insulin.InsulinLyumjevPlugin
|
||||
import info.nightscout.interfaces.insulin.Insulin
|
||||
import info.nightscout.interfaces.profile.ProfileFunction
|
||||
import info.nightscout.interfaces.ui.UiInteraction
|
||||
import info.nightscout.shared.utils.T
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.Mock
|
||||
|
@ -22,26 +22,26 @@ class BolusExtensionKtTest : TestBaseWithProfile() {
|
|||
|
||||
private val dia = 7.0
|
||||
|
||||
@BeforeEach
|
||||
fun setup() {
|
||||
@BeforeEach fun setup() {
|
||||
insulin = InsulinLyumjevPlugin(profileInjector, rh, profileFunctions, rxBus, aapsLogger, config, hardLimits, uiInteraction)
|
||||
Mockito.`when`(activePlugin.activeInsulin).thenReturn(insulin)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun iobCalc() {
|
||||
@Test fun iobCalc() {
|
||||
val bolus = Bolus(timestamp = now - 1, amount = 1.0, type = Bolus.Type.NORMAL)
|
||||
// there should be almost full IOB after now
|
||||
Assertions.assertEquals(1.0, bolus.iobCalc(activePlugin, now, dia).iobContrib, 0.01)
|
||||
assertThat(bolus.iobCalc(activePlugin, now, dia).iobContrib).isWithin(0.01).of(1.0)
|
||||
// there should be less than 5% after DIA -1
|
||||
Assertions.assertTrue(0.05 > bolus.iobCalc(activePlugin, now + T.hours(dia.toLong() - 1).msecs(), dia).iobContrib)
|
||||
assertThat(
|
||||
bolus.iobCalc(activePlugin, now + T.hours(dia.toLong() - 1).msecs(), dia).iobContrib
|
||||
).isLessThan(0.05)
|
||||
// there should be zero after DIA
|
||||
Assertions.assertEquals(0.0, bolus.iobCalc(activePlugin, now + T.hours(dia.toLong() + 1).msecs(), dia).iobContrib)
|
||||
assertThat(bolus.iobCalc(activePlugin, now + T.hours(dia.toLong() + 1).msecs(), dia).iobContrib).isEqualTo(0.0)
|
||||
// no IOB for invalid record
|
||||
bolus.isValid = false
|
||||
Assertions.assertEquals(0.0, bolus.iobCalc(activePlugin, now + T.hours(1).msecs(), dia).iobContrib)
|
||||
assertThat(bolus.iobCalc(activePlugin, now + T.hours(1).msecs(), dia).iobContrib).isEqualTo(0.0)
|
||||
bolus.isValid = true
|
||||
bolus.type = Bolus.Type.PRIMING
|
||||
Assertions.assertEquals(0.0, bolus.iobCalc(activePlugin, now + T.hours(1).msecs(), dia).iobContrib)
|
||||
assertThat(bolus.iobCalc(activePlugin, now + T.hours(1).msecs(), dia).iobContrib).isEqualTo(0.0)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue