-
Notifications
You must be signed in to change notification settings - Fork 307
Expand file tree
/
Copy pathCoverImageTest.java
More file actions
52 lines (43 loc) · 1.65 KB
/
CoverImageTest.java
File metadata and controls
52 lines (43 loc) · 1.65 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
46
47
48
49
50
51
52
package nextstep.courses.domain;
import nextstep.courses.InvalidCoverImageException;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
public class CoverImageTest {
@Test
void 유효한_커버이미지는_예외없이_생성되고_검증_통과() {
assertThatCode(() ->
new CoverImage(600, 400, 500_000, ImageExtension.JPG)
).doesNotThrowAnyException();
}
@Test
void 크기가_1MB_초과하면_예외발생() {
assertThatThrownBy(() ->
new CoverImage(600, 400, 2_000_000, ImageExtension.PNG)
).isInstanceOf(InvalidCoverImageException.class);
}
@Test
void 너비가_300미만이면_예외발생() {
assertThatThrownBy(() ->
new CoverImage(299, 400, 500_000, ImageExtension.PNG)
).isInstanceOf(InvalidCoverImageException.class);
}
@Test
void 높이가_200미만이면_예외발생() {
assertThatThrownBy(() ->
new CoverImage(600, 199, 500_000, ImageExtension.PNG)
).isInstanceOf(InvalidCoverImageException.class);
}
@Test
void 비율이_3대2_아니면_예외발생() {
assertThatThrownBy(() ->
new CoverImage(600, 500, 500_000, ImageExtension.PNG)
).isInstanceOf(InvalidCoverImageException.class);
}
@Test
void 지원하지_않는_확장자면_예외발생() {
assertThatThrownBy(() ->
new CoverImage(600, 400, 500_000, null)
).isInstanceOf(InvalidCoverImageException.class);
}
}