parent
ed726a1d29
commit
8b85e00953
1 changed files with 15 additions and 15 deletions
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
import app.aaps.core.interfaces.rx.events.EventOverviewBolusProgress
|
import app.aaps.core.interfaces.rx.events.EventOverviewBolusProgress
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
||||||
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
|
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class NotificationPacketTest : MedtrumTestBase() {
|
class NotificationPacketTest : MedtrumTestBase() {
|
||||||
|
@ -30,7 +30,7 @@ class NotificationPacketTest : MedtrumTestBase() {
|
||||||
NotificationPacket(packetInjector).handleNotification(byteArrayOf(state))
|
NotificationPacket(packetInjector).handleNotification(byteArrayOf(state))
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(medtrumPump.pumpState, MedtrumPumpState.fromByte(state))
|
assertThat(MedtrumPumpState.fromByte(state)).isEqualTo(medtrumPump.pumpState)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleNotificationGivenBasalDataThenDataSaved() {
|
@Test fun handleNotificationGivenBasalDataThenDataSaved() {
|
||||||
|
@ -41,12 +41,12 @@ class NotificationPacketTest : MedtrumTestBase() {
|
||||||
NotificationPacket(packetInjector).handleNotification(data)
|
NotificationPacket(packetInjector).handleNotification(data)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(BasalType.ABSOLUTE_TEMP, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(BasalType.ABSOLUTE_TEMP)
|
||||||
Assertions.assertEquals(0.85, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(0.85)
|
||||||
Assertions.assertEquals(25, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(25)
|
||||||
Assertions.assertEquals(14, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(14)
|
||||||
Assertions.assertEquals(1685126612000, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(1685126612000)
|
||||||
Assertions.assertEquals(186.80, medtrumPump.reservoir, 0.01)
|
assertThat(medtrumPump.reservoir).isWithin(0.01).of(186.80)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleNotificationGivenSequenceAndOtherDataThenDataSaved() {
|
@Test fun handleNotificationGivenSequenceAndOtherDataThenDataSaved() {
|
||||||
|
@ -57,7 +57,7 @@ class NotificationPacketTest : MedtrumTestBase() {
|
||||||
NotificationPacket(packetInjector).handleNotification(data)
|
NotificationPacket(packetInjector).handleNotification(data)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(167, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(167)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleNotificationGivenBolusInProgressThenDataSaved() {
|
@Test fun handleNotificationGivenBolusInProgressThenDataSaved() {
|
||||||
|
@ -69,9 +69,9 @@ class NotificationPacketTest : MedtrumTestBase() {
|
||||||
NotificationPacket(packetInjector).handleNotification(data)
|
NotificationPacket(packetInjector).handleNotification(data)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(false, medtrumPump.bolusDone)
|
assertThat(medtrumPump.bolusDone).isFalse()
|
||||||
Assertions.assertEquals(0.15, medtrumPump.bolusingTreatment!!.insulin, 0.01)
|
assertThat(medtrumPump.bolusingTreatment!!.insulin).isWithin(0.01).of(0.15)
|
||||||
Assertions.assertEquals(163.5, medtrumPump.reservoir, 0.01)
|
assertThat(medtrumPump.reservoir).isWithin(0.01).of(163.5)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleNotificationGivenBolusFinishedThenDataSaved() {
|
@Test fun handleNotificationGivenBolusFinishedThenDataSaved() {
|
||||||
|
@ -83,8 +83,8 @@ class NotificationPacketTest : MedtrumTestBase() {
|
||||||
NotificationPacket(packetInjector).handleNotification(data)
|
NotificationPacket(packetInjector).handleNotification(data)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(true, medtrumPump.bolusDone)
|
assertThat(medtrumPump.bolusDone).isTrue()
|
||||||
Assertions.assertEquals(1.65, medtrumPump.bolusingTreatment!!.insulin, 0.01)
|
assertThat(medtrumPump.bolusingTreatment!!.insulin).isWithin(0.01).of(1.65)
|
||||||
Assertions.assertEquals(161.95, medtrumPump.reservoir, 0.01)
|
assertThat(medtrumPump.reservoir).isWithin(0.01).of(161.95)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue