Skip to content

Commit

Permalink
test(AvailableDatesTest): 중복로직 검증 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
ehBeak committed Jul 24, 2024
1 parent 3674fc3 commit 71dc084
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<LocalDate> 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<LocalDate> dates = List.of(date1, date2);

// when then
assertThatCode(() -> new AvailableDates(dates, meeting))
.doesNotThrowAnyException();
}
}

0 comments on commit 71dc084

Please sign in to comment.