LImplTest

This commit is contained in:
Milos Kozak 2023-08-27 17:04:03 +02:00
parent 7321284618
commit 5dc30a1baf
2 changed files with 41 additions and 1 deletions

View file

@ -53,7 +53,7 @@ class LImpl @Inject constructor(
internal constructor(defaultValue: Boolean, sp: SP) { internal constructor(defaultValue: Boolean, sp: SP) {
this.sp = sp this.sp = sp
name = "NONEXISTING" name = "NONEXISTENT"
this.defaultValue = defaultValue this.defaultValue = defaultValue
enabled = defaultValue enabled = defaultValue
} }

View file

@ -0,0 +1,40 @@
package info.nightscout.shared.impl.logging
import info.nightscout.androidaps.TestBase
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
class LImplTest : TestBase() {
@Mock lateinit var sp: SP
private lateinit var sut: LImpl
@BeforeEach
fun setUp() {
sut = LImpl(sp)
}
@Test
fun findByName() {
Assertions.assertEquals(LTag.APS.name, sut.findByName("APS").name)
Assertions.assertEquals("NONEXISTENT", sut.findByName("APS2").name)
}
@Test
fun getLogElements() {
Assertions.assertTrue(sut.getLogElements().isNotEmpty())
}
@Test
fun resetToDefaults() {
val element = sut.findByName("APS")
element.enabled = false
sut.resetToDefaults()
Assertions.assertTrue(element.enabled)
}
}