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 Original file line number Diff line number Diff line change 1
1
package br.com.mob1st.features.finances.impl.domain.values
2
2
3
+ import kotlinx.datetime.Month
3
4
import org.junit.jupiter.api.Assertions.assertEquals
4
5
import org.junit.jupiter.params.ParameterizedTest
5
6
import org.junit.jupiter.params.provider.Arguments.arguments
6
7
import org.junit.jupiter.params.provider.MethodSource
7
8
import java.util.Locale
8
- import kotlin.test.Test
9
- import kotlin.test.assertFalse
10
9
11
10
class DayOfYearTest {
12
11
@ParameterizedTest
@@ -25,9 +24,31 @@ class DayOfYearTest {
25
24
)
26
25
}
27
26
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
+ )
31
52
}
32
53
33
54
companion object {
@@ -88,5 +109,81 @@ class DayOfYearTest {
88
109
" 31 Dec" ,
89
110
),
90
111
)
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
+ )
91
188
}
92
189
}
You can’t perform that action at this time.
0 commit comments