parent
d75bf0e611
commit
d24d97cc4b
1 changed files with 7 additions and 8 deletions
|
@ -1,9 +1,9 @@
|
||||||
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 org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class StopPatchPacketTest : MedtrumTestBase() {
|
class StopPatchPacketTest : MedtrumTestBase() {
|
||||||
|
@ -28,8 +28,7 @@ class StopPatchPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(1, result.size)
|
assertThat(result).asList().containsExactly(opCode.toByte())
|
||||||
Assertions.assertEquals(opCode.toByte(), result[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
||||||
|
@ -43,9 +42,9 @@ class StopPatchPacketTest : MedtrumTestBase() {
|
||||||
// Expected values
|
// Expected values
|
||||||
val expectedPatchId = 146L
|
val expectedPatchId = 146L
|
||||||
val expectedStopSequence = 23
|
val expectedStopSequence = 23
|
||||||
Assertions.assertTrue(result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(expectedPatchId, medtrumPump.lastStopPatchId)
|
assertThat(medtrumPump.lastStopPatchId).isEqualTo(expectedPatchId)
|
||||||
Assertions.assertEquals(expectedStopSequence, medtrumPump.lastStopSequence)
|
assertThat(medtrumPump.lastStopSequence).isEqualTo(expectedStopSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -57,7 +56,7 @@ class StopPatchPacketTest : 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