Skip to content

Commit

Permalink
shared-tests #11
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosKozak committed Sep 4, 2023
1 parent 3c5a58b commit 8032cd8
Show file tree
Hide file tree
Showing 32 changed files with 251 additions and 525 deletions.
1 change: 1 addition & 0 deletions pump/medtrum/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ dependencies {
implementation project(':pump:pump-common')
implementation project(':core:utils')

testImplementation project(':app-wear-shared:shared-tests')
testImplementation project(':core:main')
}

This file was deleted.

38 changes: 0 additions & 38 deletions pump/medtrum/src/test/java/info/nightscout/androidaps/TestBase.kt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package info.nightscout.pump.medtrum
import info.nightscout.core.extensions.pureProfileFromJson
import info.nightscout.core.profile.ProfileSealed
import org.json.JSONObject
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.Assert.*
import java.time.LocalDate
import java.time.LocalTime
import java.time.ZoneId
Expand Down Expand Up @@ -33,7 +33,7 @@ class MedtrumPumpTest : MedtrumTestBase() {

// Expected values
val expectedByteArray = byteArrayOf(7, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -20, 36, 2, 100, -123, 2)
assertEquals(expectedByteArray.contentToString(), result?.contentToString())
Assertions.assertEquals(expectedByteArray.contentToString(), result?.contentToString())
}

@Test fun buildMedtrumProfileArrayGiveProfileWhenValuesTooHighThenReturnNull() {
Expand All @@ -50,7 +50,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
val result = medtrumPump.buildMedtrumProfileArray(profile)

// Expected values
assertNull(result)
Assertions.assertNull(result)
}

@Test fun getCurrentHourlyBasalFromMedtrumProfileArrayGivenProfileWhenValuesSetThenReturnCorrectValue() {
Expand Down Expand Up @@ -78,27 +78,27 @@ class MedtrumPumpTest : MedtrumTestBase() {
val zonedDateTime0399 = localDate.atTime(localTime0399).atZone(ZoneId.systemDefault())
val time0399 = zonedDateTime0399.toInstant().toEpochMilli()
val result = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray!!, time0399)
assertEquals(2.1, result, 0.01)
Assertions.assertEquals(2.1, result, 0.01)

// For 22:30
val localTime2230 = LocalTime.of(22, 30)
val zonedDateTime2230 = localDate.atTime(localTime2230).atZone(ZoneId.systemDefault())
val time2230 = zonedDateTime2230.toInstant().toEpochMilli()
val result1 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time2230)
assertEquals(1.7, result1, 0.01)
Assertions.assertEquals(1.7, result1, 0.01)

// For 23:59
val localTime2359 = LocalTime.of(23, 59)
val zonedDateTime2359 = localDate.atTime(localTime2359).atZone(ZoneId.systemDefault())
val time2359 = zonedDateTime2359.toInstant().toEpochMilli()
val result2 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time2359)
assertEquals(2.0, result2, 0.01)
Assertions.assertEquals(2.0, result2, 0.01)

// For 00:00
val localTime0000 = LocalTime.of(0, 0)
val zonedDateTime0000 = localDate.atTime(localTime0000).atZone(ZoneId.systemDefault())
val time0000 = zonedDateTime0000.toInstant().toEpochMilli()
val result3 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time0000)
assertEquals(2.1, result3, 0.01)
Assertions.assertEquals(2.1, result3, 0.01)
}
}
Loading

0 comments on commit 8032cd8

Please sign in to comment.