diff --git a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_functional/FunctionalTimer.kt b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_functional/FunctionalTimer.kt index 5d06207..dd01924 100644 --- a/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_functional/FunctionalTimer.kt +++ b/app/src/main/java/be/ugent/sel/studeez/data/local/models/timer_functional/FunctionalTimer.kt @@ -1,7 +1,7 @@ package be.ugent.sel.studeez.data.local.models.timer_functional abstract class FunctionalTimer(initialValue: Int) { - protected val time: Time = Time(initialValue) + val time: Time = Time(initialValue) var view: String = "Focus" fun getHoursMinutesSeconds(): HoursMinutesSeconds { diff --git a/app/src/test/java/be/ugent/sel/studeez/FunctionalCustomTimerUnitTest.kt b/app/src/test/java/be/ugent/sel/studeez/FunctionalCustomTimerUnitTest.kt new file mode 100644 index 0000000..9a875cd --- /dev/null +++ b/app/src/test/java/be/ugent/sel/studeez/FunctionalCustomTimerUnitTest.kt @@ -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 + ) + } +} \ No newline at end of file diff --git a/app/src/test/java/be/ugent/sel/studeez/FunctionalTimerUnitTest.kt b/app/src/test/java/be/ugent/sel/studeez/FunctionalTimerUnitTest.kt new file mode 100644 index 0000000..996dae5 --- /dev/null +++ b/app/src/test/java/be/ugent/sel/studeez/FunctionalTimerUnitTest.kt @@ -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() +} \ No newline at end of file diff --git a/app/src/test/java/be/ugent/sel/studeez/TimeUnitTest.kt b/app/src/test/java/be/ugent/sel/studeez/TimeUnitTest.kt index 567ef18..f15c821 100644 --- a/app/src/test/java/be/ugent/sel/studeez/TimeUnitTest.kt +++ b/app/src/test/java/be/ugent/sel/studeez/TimeUnitTest.kt @@ -58,7 +58,7 @@ class TimeUnitTest { @Test fun minMultiple() { val n = 10 - for (i in 1..n) { + for (i in 1 .. n) { time.minOne() } Assert.assertEquals( @@ -70,7 +70,7 @@ class TimeUnitTest { @Test fun plusMultiple() { val n = 10 - for (i in 1..n) { + for (i in 1 .. n) { time.plusOne() } Assert.assertEquals(