Rewrites SmsActionTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-09-23 18:54:29 -07:00
parent 2cbcf8bd50
commit 2975da80c2

View file

@ -1,6 +1,6 @@
package info.nightscout.plugins.general.smsCommunicator
import org.junit.jupiter.api.Assertions
import com.google.common.truth.Truth.assertThat
import org.junit.jupiter.api.Test
class SmsActionTest {
@ -13,49 +13,49 @@ class SmsActionTest {
}
}
smsAction.run()
Assertions.assertEquals(result, "A")
assertThat(result).isEqualTo("A")
smsAction = object : SmsAction(false, 1.0) {
override fun run() {
result = "B"
}
}
smsAction.run()
Assertions.assertEquals(result, "B")
Assertions.assertEquals(smsAction.aDouble(), 1.0, 0.000001)
assertThat(result).isEqualTo("B")
assertThat(smsAction.aDouble()).isWithin(0.000001).of(1.0)
smsAction = object : SmsAction(false, 1.0, 2) {
override fun run() {
result = "C"
}
}
smsAction.run()
Assertions.assertEquals(result, "C")
Assertions.assertEquals(smsAction.aDouble(), 1.0, 0.000001)
Assertions.assertEquals(smsAction.secondInteger().toLong(), 2)
assertThat(result).isEqualTo("C")
assertThat(smsAction.aDouble()).isWithin(0.000001).of(1.0)
assertThat(smsAction.secondInteger().toLong()).isEqualTo(2)
smsAction = object : SmsAction(false, "aString", 3) {
override fun run() {
result = "D"
}
}
smsAction.run()
Assertions.assertEquals(result, "D")
Assertions.assertEquals(smsAction.aString(), "aString")
Assertions.assertEquals(smsAction.secondInteger().toLong(), 3)
assertThat(result).isEqualTo("D")
assertThat(smsAction.aString()).isEqualTo("aString")
assertThat(smsAction.secondInteger().toLong()).isEqualTo(3)
smsAction = object : SmsAction(false, 4) {
override fun run() {
result = "E"
}
}
smsAction.run()
Assertions.assertEquals(result, "E")
Assertions.assertEquals(smsAction.anInteger().toLong(), 4)
assertThat(result).isEqualTo("E")
assertThat(smsAction.anInteger().toLong()).isEqualTo(4)
smsAction = object : SmsAction(false, 5, 6) {
override fun run() {
result = "F"
}
}
smsAction.run()
Assertions.assertEquals(result, "F")
Assertions.assertEquals(smsAction.anInteger().toLong(), 5)
Assertions.assertEquals(smsAction.secondInteger().toLong(), 6)
assertThat(result).isEqualTo("F")
assertThat(smsAction.anInteger().toLong()).isEqualTo(5)
assertThat(smsAction.secondInteger().toLong()).isEqualTo(6)
}
}