Introduce HabitType and NumericalHabitType enums

This commit is contained in:
Quentin Hibon
2021-08-04 17:40:10 +02:00
committed by Alinson S. Xavier
parent 95a1786c4a
commit b9eb244b0b
10 changed files with 90 additions and 58 deletions

View File

@@ -84,8 +84,8 @@ class HabitTest : BaseUnitTest() {
@Throws(Exception::class)
fun test_isCompleted_numerical() {
val h = modelFactory.buildHabit()
h.type = Habit.NUMBER_HABIT
h.targetType = Habit.AT_LEAST
h.type = HabitType.NUMERICAL
h.targetType = NumericalHabitType.AT_LEAST
h.targetValue = 100.0
assertFalse(h.isCompletedToday())
h.originalEntries.add(Entry(getToday(), 200000))
@@ -97,7 +97,7 @@ class HabitTest : BaseUnitTest() {
h.originalEntries.add(Entry(getToday(), 50000))
h.recompute()
assertFalse(h.isCompletedToday())
h.targetType = Habit.AT_MOST
h.targetType = NumericalHabitType.AT_MOST
h.originalEntries.add(Entry(getToday(), 200000))
h.recompute()
assertFalse(h.isCompletedToday())

View File

@@ -22,7 +22,8 @@ import org.hamcrest.CoreMatchers.equalTo
import org.hamcrest.MatcherAssert.assertThat
import org.isoron.uhabits.core.BaseUnitTest
import org.isoron.uhabits.core.models.Frequency
import org.isoron.uhabits.core.models.Habit
import org.isoron.uhabits.core.models.HabitType
import org.isoron.uhabits.core.models.NumericalHabitType
import org.isoron.uhabits.core.models.PaletteColor
import org.isoron.uhabits.core.models.Reminder
import org.isoron.uhabits.core.models.WeekdayList
@@ -59,9 +60,9 @@ class HabitRecordTest : BaseUnitTest() {
reminder = null
id = 1L
position = 15
type = Habit.NUMBER_HABIT
type = HabitType.NUMERICAL
targetValue = 100.0
targetType = Habit.AT_LEAST
targetType = NumericalHabitType.AT_LEAST
unit = "miles"
}
val record = HabitRecord()