fix tests
This commit is contained in:
parent
a9a3586d07
commit
3acd1f8a9c
2 changed files with 14 additions and 35 deletions
|
@ -1,53 +1,23 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions
|
package info.nightscout.androidaps.plugins.general.automation.actions
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
|
||||||
import dagger.android.HasAndroidInjector
|
|
||||||
import info.nightscout.androidaps.TestBase
|
|
||||||
import info.nightscout.androidaps.automation.R
|
import info.nightscout.androidaps.automation.R
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
|
||||||
import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
||||||
import info.nightscout.androidaps.database.transactions.Transaction
|
import info.nightscout.androidaps.database.transactions.Transaction
|
||||||
import info.nightscout.androidaps.interfaces.GlucoseUnit
|
import info.nightscout.androidaps.interfaces.GlucoseUnit
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputCarePortalMenu
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputCarePortalMenu
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputString
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputString
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
|
||||||
import io.reactivex.Completable
|
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.ArgumentMatchers
|
import org.mockito.ArgumentMatchers
|
||||||
import org.mockito.Mock
|
|
||||||
import org.mockito.Mockito
|
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
import org.mockito.Mockito.any
|
|
||||||
import org.mockito.Mockito.doNothing
|
|
||||||
|
|
||||||
class ActionCarePortalEventTest : TestBase() {
|
class ActionCarePortalEventTest : ActionsTestBase() {
|
||||||
|
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
|
||||||
@Mock lateinit var repository: AppRepository
|
|
||||||
@Mock lateinit var sp: SP
|
|
||||||
@Mock lateinit var dateUtil: DateUtil
|
|
||||||
@Mock lateinit var profileFunction: ProfileFunction
|
|
||||||
|
|
||||||
private lateinit var sut: ActionCarePortalEvent
|
private lateinit var sut: ActionCarePortalEvent
|
||||||
var injector: HasAndroidInjector = HasAndroidInjector {
|
|
||||||
AndroidInjector {
|
|
||||||
if (it is ActionCarePortalEvent) {
|
|
||||||
it.resourceHelper = resourceHelper
|
|
||||||
it.repository = repository
|
|
||||||
it.sp = sp
|
|
||||||
it.dateUtil = dateUtil
|
|
||||||
it.profileFunction = profileFunction
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
|
@ -60,8 +30,9 @@ class ActionCarePortalEventTest : TestBase() {
|
||||||
).thenReturn("Note : %s")
|
).thenReturn("Note : %s")
|
||||||
`when`(dateUtil.now()).thenReturn(0)
|
`when`(dateUtil.now()).thenReturn(0)
|
||||||
`when`(profileFunction.getUnits()).thenReturn(GlucoseUnit.MGDL)
|
`when`(profileFunction.getUnits()).thenReturn(GlucoseUnit.MGDL)
|
||||||
`when`(repository.runTransaction(anyObject<Transaction<InsertIfNewByTimestampTherapyEventTransaction.TransactionResult>>()))
|
`when`(repository.runTransactionForResult(anyObject<Transaction<InsertIfNewByTimestampTherapyEventTransaction.TransactionResult>>()))
|
||||||
.thenReturn(Completable.fromAction {})
|
.thenReturn(Single.just(InsertIfNewByTimestampTherapyEventTransaction.TransactionResult().apply {
|
||||||
|
}))
|
||||||
sut = ActionCarePortalEvent(injector)
|
sut = ActionCarePortalEvent(injector)
|
||||||
sut.cpEvent = InputCarePortalMenu(resourceHelper)
|
sut.cpEvent = InputCarePortalMenu(resourceHelper)
|
||||||
sut.cpEvent.value = InputCarePortalMenu.EventType.NOTE
|
sut.cpEvent.value = InputCarePortalMenu.EventType.NOTE
|
||||||
|
@ -80,7 +51,7 @@ class ActionCarePortalEventTest : TestBase() {
|
||||||
@Test fun iconTest() {
|
@Test fun iconTest() {
|
||||||
Assert.assertEquals(R.drawable.ic_cp_note, sut.icon())
|
Assert.assertEquals(R.drawable.ic_cp_note, sut.icon())
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
@Test fun doActionTest() {
|
@Test fun doActionTest() {
|
||||||
sut.doAction(object : Callback() {
|
sut.doAction(object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
@ -88,7 +59,7 @@ class ActionCarePortalEventTest : TestBase() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
@Test fun hasDialogTest() {
|
@Test fun hasDialogTest() {
|
||||||
Assert.assertTrue(sut.hasDialog())
|
Assert.assertTrue(sut.hasDialog())
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,14 @@ open class ActionsTestBase : TestBaseWithProfile() {
|
||||||
it.rxBus = rxBus
|
it.rxBus = rxBus
|
||||||
it.uel = uel
|
it.uel = uel
|
||||||
}
|
}
|
||||||
|
if (it is ActionCarePortalEvent) {
|
||||||
|
it.resourceHelper = resourceHelper
|
||||||
|
it.repository = repository
|
||||||
|
it.sp = sp
|
||||||
|
it.dateUtil = dateUtil
|
||||||
|
it.profileFunction = profileFunction
|
||||||
|
it.uel = uel
|
||||||
|
}
|
||||||
if (it is PumpEnactResult) {
|
if (it is PumpEnactResult) {
|
||||||
it.resourceHelper = resourceHelper
|
it.resourceHelper = resourceHelper
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue