Rewrites ReadBolusStatePacketTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-10-08 17:38:25 -07:00
parent 7055ced8db
commit 59d81e47de

View file

@ -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 ReadBolusStatePacketTest : MedtrumTestBase() { class ReadBolusStatePacketTest : MedtrumTestBase() {
@ -31,9 +31,9 @@ class ReadBolusStatePacketTest : MedtrumTestBase() {
val result = packet.handleResponse(response) val result = packet.handleResponse(response)
// Expected values // Expected values
Assertions.assertTrue(result) assertThat(result).isTrue()
Assertions.assertFalse(packet.failed) assertThat(packet.failed).isFalse()
Assertions.assertEquals(bolusData.contentToString(), packet.bolusData.contentToString()) assertThat(packet.bolusData).isEqualTo(bolusData)
} }
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() { @Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
@ -47,8 +47,8 @@ class ReadBolusStatePacketTest : 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()
Assertions.assertEquals(byteArrayOf().contentToString(), packet.bolusData.contentToString()) assertThat(packet.bolusData).isEmpty()
} }
} }