parent
82731361c6
commit
b83e19ea6a
1 changed files with 12 additions and 12 deletions
|
@ -2,10 +2,10 @@ package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.comm.enums.AlarmSetting
|
import info.nightscout.pump.medtrum.comm.enums.AlarmSetting
|
||||||
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class ActivatePacketTest : MedtrumTestBase() {
|
class ActivatePacketTest : MedtrumTestBase() {
|
||||||
|
@ -38,7 +38,7 @@ class ActivatePacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expectedByteArray = byteArrayOf(18, 0, 12, 1, 6, 0, 0, 30, 32, 3, 16, 14, 0, 0, 1, 3, 16, 14, 0, 0, 1, 2, 12, 12, 12)
|
val expectedByteArray = byteArrayOf(18, 0, 12, 1, 6, 0, 0, 30, 32, 3, 16, 14, 0, 0, 1, 3, 16, 14, 0, 0, 1, 2, 12, 12, 12)
|
||||||
Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString())
|
assertThat(result.contentToString()).isEqualTo(expectedByteArray.contentToString())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
||||||
|
@ -64,15 +64,15 @@ class ActivatePacketTest : MedtrumTestBase() {
|
||||||
val expectedBasalPatchId = 41L
|
val expectedBasalPatchId = 41L
|
||||||
val expectedBasalStart = 1675605528000L
|
val expectedBasalStart = 1675605528000L
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(expectedPatchId, medtrumPump.patchId)
|
assertThat(medtrumPump.patchId).isEqualTo(expectedPatchId)
|
||||||
Assertions.assertEquals(expectedTime, medtrumPump.lastTimeReceivedFromPump)
|
assertThat(medtrumPump.lastTimeReceivedFromPump).isEqualTo(expectedTime)
|
||||||
Assertions.assertEquals(expectedBasalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(expectedBasalType)
|
||||||
Assertions.assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(expectedBasalRate)
|
||||||
Assertions.assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(expectedBasalSequence)
|
||||||
Assertions.assertEquals(expectedBasalPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(expectedBasalPatchId)
|
||||||
Assertions.assertEquals(expectedBasalStart, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(expectedBasalStart)
|
||||||
Assertions.assertEquals(basalProfile, medtrumPump.actualBasalProfile)
|
assertThat(medtrumPump.actualBasalProfile).isEqualTo(basalProfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -84,6 +84,6 @@ class ActivatePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertFalse(result)
|
assertThat(result).isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue