parent
764ae29e56
commit
ed726a1d29
1 changed files with 12 additions and 13 deletions
|
@ -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.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 MedtrumPacketTest : MedtrumTestBase() {
|
class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
|
@ -29,8 +29,7 @@ class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(result.size, 1)
|
assertThat(result).asList().containsExactly(opCode.toByte())
|
||||||
Assertions.assertEquals(result[0], opCode.toByte())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenOpcodeIsCorrectThenResultTrue() {
|
@Test fun handleResponseGivenResponseWhenOpcodeIsCorrectThenResultTrue() {
|
||||||
|
@ -45,8 +44,8 @@ class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(result, true)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(packet.failed, false)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenOpcodeIsIncorrectThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenOpcodeIsIncorrectThenResultFalse() {
|
||||||
|
@ -61,8 +60,8 @@ class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(result, false)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(packet.failed, true)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenResponseCodeIsWaitingThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenResponseCodeIsWaitingThenResultFalse() {
|
||||||
|
@ -77,8 +76,8 @@ class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(result, false)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(packet.failed, false)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenResponseCodeIsErrorThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenResponseCodeIsErrorThenResultFalse() {
|
||||||
|
@ -93,8 +92,8 @@ class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(false, result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(true, packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -108,7 +107,7 @@ class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(false, result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(true, packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue