parent
b83e19ea6a
commit
c95654c0ac
1 changed files with 8 additions and 9 deletions
|
@ -1,11 +1,11 @@
|
||||||
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.MedtrumPump
|
import info.nightscout.pump.medtrum.MedtrumPump
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.extension.toByteArray
|
import info.nightscout.pump.medtrum.extension.toByteArray
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class AuthorizePacketTest : MedtrumTestBase() {
|
class AuthorizePacketTest : MedtrumTestBase() {
|
||||||
|
@ -37,8 +37,7 @@ class AuthorizePacketTest : MedtrumTestBase() {
|
||||||
val key = 3364239851
|
val key = 3364239851
|
||||||
val type = 2
|
val type = 2
|
||||||
val expectedByteArray = byteArrayOf(opCode.toByte()) + type.toByte() + medtrumPump.patchSessionToken.toByteArray(4) + key.toByteArray(4)
|
val expectedByteArray = byteArrayOf(opCode.toByte()) + type.toByte() + medtrumPump.patchSessionToken.toByteArray(4) + key.toByteArray(4)
|
||||||
Assertions.assertEquals(10, result.size)
|
assertThat(result).asList().containsExactlyElementsIn(expectedByteArray.toList()).inOrder()
|
||||||
Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() {
|
@Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() {
|
||||||
|
@ -57,10 +56,10 @@ class AuthorizePacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val swString = "$swVerX.$swVerY.$swVerZ"
|
val swString = "$swVerX.$swVerY.$swVerZ"
|
||||||
Assertions.assertTrue(result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertFalse(packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
Assertions.assertEquals(deviceType, medtrumPump.deviceType)
|
assertThat(medtrumPump.deviceType).isEqualTo(deviceType)
|
||||||
Assertions.assertEquals(swString, medtrumPump.swVersion)
|
assertThat(medtrumPump.swVersion).isEqualTo(swString)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -75,7 +74,7 @@ class AuthorizePacketTest : 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