-
Notifications
You must be signed in to change notification settings - Fork 307
Expand file tree
/
Copy pathSessionTest.java
More file actions
42 lines (33 loc) · 1.4 KB
/
SessionTest.java
File metadata and controls
42 lines (33 loc) · 1.4 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
package nextstep.courses.domain;
import nextstep.courses.CannotEnrollSessionException;
import nextstep.payments.domain.PaidEnrollmentPolicy;
import org.junit.jupiter.api.Test;
import java.time.LocalDate;
import static nextstep.payments.PaymentTest.PAYMENT_1000;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
public class SessionTest {
public static final Session ReadySession = new Session(
LocalDate.of(2025, 1, 1),
LocalDate.of(2025, 12, 31),
new CoverImage(600, 400, 500_000, ImageExtension.JPG),
SessionStatus.READY,
new PaidEnrollmentPolicy(100, 1000));
public static final Session EnrollingSession = new Session(
LocalDate.of(2025, 1, 1),
LocalDate.of(2025, 12, 31),
new CoverImage(600, 400, 500_000, ImageExtension.JPG),
SessionStatus.ENROLLING,
new PaidEnrollmentPolicy(100, 1000));
@Test
void 모집중이_아닐_때_수강신청_불가능() {
assertThatThrownBy(() ->
ReadySession.enroll(PAYMENT_1000)
).isInstanceOf(CannotEnrollSessionException.class);
}
@Test
void 모집중일_때_수강신청_가능() {
assertThatCode(() -> EnrollingSession.enroll(PAYMENT_1000))
.doesNotThrowAnyException();
}
}