-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathLottoTest.java
More file actions
45 lines (34 loc) · 1.42 KB
/
LottoTest.java
File metadata and controls
45 lines (34 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package lotto.domain;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
public class LottoTest {
@Test
void 로또_번호_6개로_생성() {
Lotto lotto = new Lotto(1, 2, 3, 4, 5, 6);
assertThat(lotto.getNumbers()).hasSize(6);
}
@Test
void 로또_번호_6개가_아니면_예외발생() {
assertThatThrownBy(() -> new Lotto(1, 2, 3, 4, 5))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("로또 번호는 중복없이 6개여야 합니다.");
}
@Test
void 로또_번호가_중복되면_예외발생() {
assertThatThrownBy(() -> new Lotto(1, 2, 3, 4, 5, 5))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("로또 번호는 중복없이 6개여야 합니다.");
}
@Test
void 로또_번호_범위가_1에서_45가_아니면_예외발생() {
assertThatThrownBy(() -> new Lotto(1, 2, 3, 4, 5, 46))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("로또 번호는 1부터 45 사이의 숫자여야 한다");
}
@Test
void 로또_번호가_오름차순으로_정렬되어_저장됨() {
Lotto lotto = new Lotto(6, 5, 4, 3, 2, 1);
assertThat(lotto.getNumbers()).containsExactly(1, 2, 3, 4, 5, 6);
}
}