more CommandQueue tests
This commit is contained in:
parent
531c74de6a
commit
2b3fcc60f0
2 changed files with 38 additions and 1 deletions
|
@ -15,6 +15,7 @@ import org.json.JSONObject
|
||||||
class TestPumpPlugin(val injector: HasAndroidInjector) : PumpInterface {
|
class TestPumpPlugin(val injector: HasAndroidInjector) : PumpInterface {
|
||||||
|
|
||||||
var connected = false
|
var connected = false
|
||||||
|
var isProfileSet = true
|
||||||
|
|
||||||
override fun isConnected() = connected
|
override fun isConnected() = connected
|
||||||
override fun isConnecting() = false
|
override fun isConnecting() = false
|
||||||
|
@ -42,7 +43,7 @@ class TestPumpPlugin(val injector: HasAndroidInjector) : PumpInterface {
|
||||||
override fun waitForDisconnectionInSeconds(): Int = 0
|
override fun waitForDisconnectionInSeconds(): Int = 0
|
||||||
override fun getPumpStatus(reason: String) {}
|
override fun getPumpStatus(reason: String) {}
|
||||||
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector)
|
override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector)
|
||||||
override fun isThisProfileSet(profile: Profile): Boolean = true
|
override fun isThisProfileSet(profile: Profile): Boolean = isProfileSet
|
||||||
override fun lastDataTime(): Long = lastData
|
override fun lastDataTime(): Long = lastData
|
||||||
override val baseBasalRate: Double = baseBasal
|
override val baseBasalRate: Double = baseBasal
|
||||||
override val reservoirLevel: Double = 0.0
|
override val reservoirLevel: Double = 0.0
|
||||||
|
|
|
@ -344,6 +344,42 @@ class CommandQueueTest : TestBaseWithProfile() {
|
||||||
Assert.assertEquals(1, commandQueue.size())
|
Assert.assertEquals(1, commandQueue.size())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun isProfileSetCommandInQueue() {
|
||||||
|
// given
|
||||||
|
Assert.assertEquals(0, commandQueue.size())
|
||||||
|
|
||||||
|
// when
|
||||||
|
testPumpPlugin.isProfileSet = true
|
||||||
|
commandQueue.setProfile(validProfile, object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
Assert.assertTrue(result.success)
|
||||||
|
Assert.assertFalse(result.enacted)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// then
|
||||||
|
// the same profile -> ignore
|
||||||
|
Assert.assertEquals(0, commandQueue.size())
|
||||||
|
// different should be added
|
||||||
|
testPumpPlugin.isProfileSet = false
|
||||||
|
commandQueue.setProfile(validProfile, object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
Assert.assertTrue(result.success)
|
||||||
|
Assert.assertTrue(result.enacted)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Assert.assertEquals(1, commandQueue.size())
|
||||||
|
// next should be ignored
|
||||||
|
commandQueue.setProfile(validProfile, object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
Assert.assertTrue(result.success)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Assert.assertEquals(1, commandQueue.size())
|
||||||
|
testPumpPlugin.isProfileSet = true
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isStopCommandInQueue() {
|
fun isStopCommandInQueue() {
|
||||||
// given
|
// given
|
||||||
|
|
Loading…
Reference in a new issue