forked from techeer-sv/Infinite_Challenge_BE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
지하철 등록 techeer-sv#1 feat : 새로운 역 등록 기능 구현 및 예외 처리
- Loading branch information
1 parent
a420b17
commit 8307c3a
Showing
4 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,45 @@ | ||
package subway; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import subway.domain.LineRepository; | ||
import subway.domain.StationRepository; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class SubwayServiceTest { | ||
SubwayService subwayService; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
subwayService = new SubwayService(); | ||
} | ||
|
||
@Nested | ||
@DisplayName("역 등록 테스트") | ||
class AddStationTest { | ||
|
||
@Test | ||
@DisplayName("새로운 역을 등록") | ||
void addStation() { | ||
subwayService.addStation("잠실역"); | ||
assertTrue(StationRepository.isStationExist("잠실역")); | ||
} | ||
|
||
@Test | ||
@DisplayName("중복된 역 검증") | ||
void duplicationStation() { | ||
subwayService.addStation("잠실역"); | ||
assertThrows(IllegalArgumentException.class, () -> subwayService.addStation("잠실역")); | ||
} | ||
|
||
@Test | ||
@DisplayName("역 이름은 2글자 이상이어야 한다.") | ||
void invalidStationName() { | ||
assertThrows(IllegalArgumentException.class, () -> subwayService.addStation("짱")); | ||
} | ||
} | ||
} |