Rewrites SetTimePacketTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-10-08 18:17:44 -07:00
parent b560313e75
commit 58dd9692de

View file

@ -1,11 +1,11 @@
package info.nightscout.pump.medtrum.comm.packets
import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.pump.medtrum.MedtrumTestBase
import info.nightscout.pump.medtrum.extension.toByteArray
import info.nightscout.pump.medtrum.util.MedtrumTimeUtil
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
class SetTimePacketTest : MedtrumTestBase() {
@ -30,8 +30,7 @@ class SetTimePacketTest : MedtrumTestBase() {
val result = packet.getRequest()
// Expected values
val expectedByteArray = byteArrayOf(opCode.toByte()) + 2.toByte() + time.toByteArray(4)
Assertions.assertEquals(6, result.size)
Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString())
val expected = byteArrayOf(opCode.toByte()) + 2.toByte() + time.toByteArray(4)
assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder()
}
}