#57 FunctionalCustomTimer unit test
This commit is contained in:
parent
9834ce4a06
commit
55b35073c7
4 changed files with 66 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
package be.ugent.sel.studeez.data.local.models.timer_functional
|
package be.ugent.sel.studeez.data.local.models.timer_functional
|
||||||
|
|
||||||
abstract class FunctionalTimer(initialValue: Int) {
|
abstract class FunctionalTimer(initialValue: Int) {
|
||||||
protected val time: Time = Time(initialValue)
|
val time: Time = Time(initialValue)
|
||||||
var view: String = "Focus"
|
var view: String = "Focus"
|
||||||
|
|
||||||
fun getHoursMinutesSeconds(): HoursMinutesSeconds {
|
fun getHoursMinutesSeconds(): HoursMinutesSeconds {
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package be.ugent.sel.studeez
|
||||||
|
|
||||||
|
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalCustomTimer
|
||||||
|
import org.junit.Assert
|
||||||
|
|
||||||
|
class FunctionalCustomTimerUnitTest: FunctionalTimerUnitTest() {
|
||||||
|
override fun setup() {
|
||||||
|
timer = FunctionalCustomTimer(time)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun testOneTick() {
|
||||||
|
timer.tick()
|
||||||
|
Assert.assertEquals(
|
||||||
|
time - 1,
|
||||||
|
timer.time.time,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun multipleTicks() {
|
||||||
|
val n = 10
|
||||||
|
for (i in 1 .. n) {
|
||||||
|
timer.tick()
|
||||||
|
}
|
||||||
|
Assert.assertEquals(
|
||||||
|
time - n,
|
||||||
|
timer.time.time,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun testEnded() {
|
||||||
|
timer = FunctionalCustomTimer(0)
|
||||||
|
timer.tick()
|
||||||
|
Assert.assertEquals(
|
||||||
|
"Done!",
|
||||||
|
timer.view
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package be.ugent.sel.studeez
|
||||||
|
|
||||||
|
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
abstract class FunctionalTimerUnitTest {
|
||||||
|
protected lateinit var timer: FunctionalTimer
|
||||||
|
private val hours = 4
|
||||||
|
private val minutes = 20
|
||||||
|
private val seconds = 39
|
||||||
|
protected val time = seconds + minutes * 60 + hours * 60 * 60
|
||||||
|
|
||||||
|
@Before
|
||||||
|
abstract fun setup()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
abstract fun testOneTick()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
abstract fun multipleTicks()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
abstract fun testEnded()
|
||||||
|
}
|
Reference in a new issue