Skip to content

Commit 19d9faa

Browse files
committed
fix unit test
1 parent 296ef28 commit 19d9faa

File tree

1 file changed

+102
-5
lines changed
  • features/finances/impl/src/test/kotlin/br/com/mob1st/features/finances/impl/domain/values

1 file changed

+102
-5
lines changed

Diff for: features/finances/impl/src/test/kotlin/br/com/mob1st/features/finances/impl/domain/values/DayOfYearTest.kt

+102-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package br.com.mob1st.features.finances.impl.domain.values
22

3+
import kotlinx.datetime.Month
34
import org.junit.jupiter.api.Assertions.assertEquals
45
import org.junit.jupiter.params.ParameterizedTest
56
import org.junit.jupiter.params.provider.Arguments.arguments
67
import org.junit.jupiter.params.provider.MethodSource
78
import java.util.Locale
8-
import kotlin.test.Test
9-
import kotlin.test.assertFalse
109

1110
class DayOfYearTest {
1211
@ParameterizedTest
@@ -25,9 +24,31 @@ class DayOfYearTest {
2524
)
2625
}
2726

28-
@Test
29-
fun test() {
30-
assertFalse(true)
27+
@ParameterizedTest
28+
@MethodSource("monthToDaySource")
29+
fun `GIVEN a month WHEN create the day of year from it THEN assert return`(
30+
month: Month,
31+
expectedDayOfYear: Int,
32+
) {
33+
val dayOfYear = DayOfYear.fromMonth(month)
34+
assertEquals(
35+
expectedDayOfYear,
36+
dayOfYear.value,
37+
)
38+
}
39+
40+
@ParameterizedTest
41+
@MethodSource("dayOfYearToMonthIndexSource")
42+
fun `GIVEN a day of year WHEN get selected month THEN assert it returns the index of the month this day belongs to`(
43+
dayOfYear: Int,
44+
expectedMonth: Int,
45+
) {
46+
val subject = DayOfYear(dayOfYear)
47+
val actual = subject.selectedMonth()
48+
assertEquals(
49+
expectedMonth,
50+
actual,
51+
)
3152
}
3253

3354
companion object {
@@ -88,5 +109,81 @@ class DayOfYearTest {
88109
"31 Dec",
89110
),
90111
)
112+
113+
@JvmStatic
114+
fun monthToDaySource() = listOf(
115+
arguments(
116+
Month.JANUARY,
117+
1,
118+
),
119+
arguments(
120+
Month.FEBRUARY,
121+
32,
122+
),
123+
arguments(
124+
Month.MARCH,
125+
60,
126+
),
127+
arguments(
128+
Month.APRIL,
129+
91,
130+
),
131+
arguments(
132+
Month.MAY,
133+
121,
134+
),
135+
arguments(
136+
Month.JUNE,
137+
152,
138+
),
139+
arguments(
140+
Month.JULY,
141+
182,
142+
),
143+
arguments(
144+
Month.AUGUST,
145+
213,
146+
),
147+
arguments(
148+
Month.SEPTEMBER,
149+
244,
150+
),
151+
arguments(
152+
Month.OCTOBER,
153+
274,
154+
),
155+
arguments(
156+
Month.NOVEMBER,
157+
305,
158+
),
159+
arguments(
160+
Month.DECEMBER,
161+
335,
162+
),
163+
)
164+
165+
@JvmStatic
166+
fun dayOfYearToMonthIndexSource() = listOf(
167+
arguments(
168+
1,
169+
0,
170+
),
171+
arguments(
172+
32,
173+
1,
174+
),
175+
arguments(
176+
60,
177+
2,
178+
),
179+
arguments(
180+
335,
181+
11,
182+
),
183+
arguments(
184+
365,
185+
11,
186+
),
187+
)
91188
}
92189
}

0 commit comments

Comments
 (0)