parent
7ebe8e1698
commit
a87ba8b708
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
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 org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class SetBasalProfilePacketTest : MedtrumTestBase() {
|
class SetBasalProfilePacketTest : MedtrumTestBase() {
|
||||||
|
@ -31,7 +31,7 @@ class SetBasalProfilePacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expected = byteArrayOf(opCode.toByte()) + 1.toByte() + basalProfile
|
val expected = byteArrayOf(opCode.toByte()) + 1.toByte() + basalProfile
|
||||||
Assertions.assertEquals(expected.contentToString(), result.contentToString())
|
assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
||||||
|
@ -50,13 +50,13 @@ class SetBasalProfilePacketTest : MedtrumTestBase() {
|
||||||
val expectedStartTime = 1679575392000L
|
val expectedStartTime = 1679575392000L
|
||||||
val expectedPatchId = 146L
|
val expectedPatchId = 146L
|
||||||
|
|
||||||
Assertions.assertTrue(result)
|
assertThat(result).isTrue()
|
||||||
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(expectedStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(expectedStartTime)
|
||||||
Assertions.assertEquals(expectedPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(expectedPatchId)
|
||||||
Assertions.assertEquals(basalProfile, medtrumPump.actualBasalProfile)
|
assertThat(medtrumPump.actualBasalProfile).isEqualTo(basalProfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -69,7 +69,7 @@ class SetBasalProfilePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertFalse(result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertTrue(packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue