Rewrites StopPatchPacketTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-10-08 18:22:05 -07:00
parent d75bf0e611
commit d24d97cc4b

View file

@ -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()
} }
} }