Skip to content

Commit

Permalink
test: AvailableDates 및 TimeslotInterval 추가된 메서드 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
seunghye218 committed Aug 6, 2024
1 parent 3116230 commit f194cfe
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@

import java.time.LocalDate;
import java.util.List;
import java.util.stream.Stream;
import kr.momo.domain.meeting.Meeting;
import kr.momo.exception.MomoException;
import kr.momo.exception.code.AvailableDateErrorCode;
import kr.momo.fixture.MeetingFixture;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;

class AvailableDatesTest {

Expand Down Expand Up @@ -98,4 +101,45 @@ void isAnyBefore(int plusDays1, int plusDays2, int plusDays3, boolean expected)

assertThat(result).isEqualTo(expected);
}

@DisplayName("start일자부터 end일 사이의 모든 날짜가 가능한 날짜인지 확인한다.")
@ParameterizedTest
@MethodSource("isNotConsecutiveDayProvider")
void isNotConsecutiveDay(List<LocalDate> dates, LocalDate startDate, LocalDate endDate, boolean expected) {
AvailableDates availableDates = new AvailableDates(dates, null);

boolean actual = availableDates.isNotConsecutiveDay(startDate, endDate);

assertThat(actual).isEqualTo(expected);
}

private static Stream<Arguments> isNotConsecutiveDayProvider() {
return Stream.of(
Arguments.of(
List.of(
LocalDate.of(2024, 8, 1),
LocalDate.of(2024, 8, 2),
LocalDate.of(2024, 8, 3)
),
LocalDate.of(2024, 8, 1),
LocalDate.of(2024, 8, 3),
false),
Arguments.of(
List.of(
LocalDate.of(2024, 8, 1),
LocalDate.of(2024, 8, 3)
),
LocalDate.of(2024, 8, 1),
LocalDate.of(2024, 8, 3),
true),
Arguments.of(
List.of(
LocalDate.of(2024, 8, 2),
LocalDate.of(2024, 8, 3)
),
LocalDate.of(2024, 8, 1),
LocalDate.of(2024, 8, 3),
true)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import java.time.LocalTime;
import java.util.stream.Stream;
import kr.momo.exception.MomoException;
import kr.momo.exception.code.ScheduleErrorCode;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

class TimeslotIntervalTest {

Expand Down Expand Up @@ -40,4 +44,25 @@ public void successfulCreationForSameStartAndEndTime() {
assertThatNoException()
.isThrownBy(() -> new TimeslotInterval(LocalTime.of(23, 30), LocalTime.of(23, 30)));
}

@DisplayName("주어진 시작 시간, 끝 시간이 포함되어 있는지 확인한다.")
@ParameterizedTest
@MethodSource("isTimeInRangeProvider")
void isTimeInRange(LocalTime startTime, LocalTime endTime, boolean expected) {
TimeslotInterval timeslotInterval = new TimeslotInterval(Timeslot.TIME_0100, Timeslot.TIME_0200);

boolean actual = timeslotInterval.isTimeInRange(startTime, endTime);

assertThat(actual).isEqualTo(expected);
}

private static Stream<Arguments> isTimeInRangeProvider() {
return Stream.of(
Arguments.of(
LocalTime.of(1, 0),
LocalTime.of(2, 30), true),
Arguments.of(
LocalTime.of(2, 0),
LocalTime.of(3, 0), false));
}
}

0 comments on commit f194cfe

Please sign in to comment.