From 71dc084970cc694083e17e43a37a9ea33b51a06a Mon Sep 17 00:00:00 2001 From: Eunhee Baek <78892355+ehBeak@users.noreply.github.com> Date: Wed, 24 Jul 2024 17:06:06 +0900 Subject: [PATCH] =?UTF-8?q?test(AvailableDatesTest):=20=EC=A4=91=EB=B3=B5?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B2=80=EC=A6=9D=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../availabledate/AvailableDatesTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 backend/src/test/java/com/woowacourse/momo/domain/availabledate/AvailableDatesTest.java diff --git a/backend/src/test/java/com/woowacourse/momo/domain/availabledate/AvailableDatesTest.java b/backend/src/test/java/com/woowacourse/momo/domain/availabledate/AvailableDatesTest.java new file mode 100644 index 000000000..aca7d2e74 --- /dev/null +++ b/backend/src/test/java/com/woowacourse/momo/domain/availabledate/AvailableDatesTest.java @@ -0,0 +1,44 @@ +package com.woowacourse.momo.domain.availabledate; + +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.woowacourse.momo.domain.meeting.Meeting; +import com.woowacourse.momo.exception.MomoException; +import com.woowacourse.momo.exception.code.AvailableDateErrorCode; +import com.woowacourse.momo.fixture.MeetingFixture; +import java.time.LocalDate; +import java.util.List; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class AvailableDatesTest { + + @DisplayName("가능한 시간의 값이 중복이면 예외가 발생한다.") + @Test + void throwExceptionWhenDuplicatedDate() { + // given + Meeting meeting = MeetingFixture.GAME.create(); + LocalDate date = LocalDate.of(2024, 7, 24); + List dates = List.of(date, date); + + // when then + assertThatThrownBy(() -> new AvailableDates(dates, meeting)) + .isInstanceOf(MomoException.class) + .hasMessage(AvailableDateErrorCode.DUPLICATED_DATE.message()); + } + + @DisplayName("가능한 시간이 중복이 아니면 예외가 발생하지 않는다.") + @Test + void createAvailableDates() { + // given + Meeting meeting = MeetingFixture.GAME.create(); + LocalDate date1 = LocalDate.of(2024, 7, 24); + LocalDate date2 = LocalDate.of(2024, 8, 25); + List dates = List.of(date1, date2); + + // when then + assertThatCode(() -> new AvailableDates(dates, meeting)) + .doesNotThrowAnyException(); + } +}