-
Notifications
You must be signed in to change notification settings - Fork 14
1단계 미션 제출합니다 #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Sehee-Lee-01
wants to merge
64
commits into
Meet-Coder-Study:Sehee-Lee-01
Choose a base branch
from
Sehee-Lee-01:level1
base: Sehee-Lee-01
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
1단계 미션 제출합니다 #8
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
11821a3
init: 초기 설정 완료
Sehee-Lee-01 bc40174
Merge branch 'Meet-Coder-Study:main' into main
Sehee-Lee-01 56c3928
init: 초기 세팅
Sehee-Lee-01 9d62464
feat: print 인터페이스 및 cli 프린터 구현
Sehee-Lee-01 78c1ac6
feat: Reader 인터페이스 및 CliReader 구현
Sehee-Lee-01 59eb6a8
feat: ExceptionHandler 구현
Sehee-Lee-01 0dadfef
feat: FlagFormatException 구현
Sehee-Lee-01 470f78c
feat: Answer 구현 및 AnswerProvider 구현
Sehee-Lee-01 b182d43
feat: Hint 구현 및 HintProvider 구현
Sehee-Lee-01 48e1169
feat:Game 인터페이스 구현 및 RandomNumberGame 구현체 구현
Sehee-Lee-01 23dbdba
feat:GamePlayer 구현
Sehee-Lee-01 e7f3248
feat:AnswerFactory 리팩토링
Sehee-Lee-01 16fa55a
feat: CliReader 리팩토링
Sehee-Lee-01 42e7279
feat: ExceptionHandler 리팩토링
Sehee-Lee-01 31f1ac4
feat: FlagFormatException 삭제
Sehee-Lee-01 bc59e32
feat: GamePlayer 리팩토링
Sehee-Lee-01 f43a077
feat: HintMaker 리팩토링
Sehee-Lee-01 ee74a9d
feat: Main 리팩토링
Sehee-Lee-01 c78951b
feat: RandomNumberGame 리팩토링
Sehee-Lee-01 c377ecd
feat: Hint 리팩토링
Sehee-Lee-01 c4096ef
feat: HintMaker 리팩토링
Sehee-Lee-01 8ca4fb0
feat: GamePlayer 리팩토링
Sehee-Lee-01 d152a58
comment: Main 주석 변경
Sehee-Lee-01 622f45d
refactor: Answer 래팩토링
Sehee-Lee-01 2c7d239
refactor: RandomNumberGameConstant 래팩토링
Sehee-Lee-01 4912d43
refactor: Main 래팩토링
Sehee-Lee-01 13d9877
refactor: Hint 래팩토링
Sehee-Lee-01 2fea609
refactor: NumberMaker 래팩토링
Sehee-Lee-01 9f7b7e8
refactor: ReadConstant 래팩토링
Sehee-Lee-01 45037fb
refactor: RandomNumberGame 래팩토링
Sehee-Lee-01 f4a484e
refactor: Answer 변수명 리팩토링
Sehee-Lee-01 756cb0d
refactor: GamePlayer 리팩토링
Sehee-Lee-01 255e65d
refactor: AnswerFactory 리팩토링
Sehee-Lee-01 04d9484
feat: exceptionHandler를 RandomNumberGame 생성자에 추가
Sehee-Lee-01 f99095d
refactor: AnswerFactory 역할 분리
Sehee-Lee-01 c2b8fd4
refactor: 패키지명 변경
Sehee-Lee-01 a45d607
rename: 클래스명 변경
Sehee-Lee-01 cfd5da2
refactor: 숫자 생성 인터페이스 생성
Sehee-Lee-01 a85e089
refactor: Hint 매서드 순서 변경
Sehee-Lee-01 a7c0270
refactor: 패키지명 변경
Sehee-Lee-01 647b959
refactor: 클래스명 변경
Sehee-Lee-01 23bc7d9
refactor: 상수 위치 변경
Sehee-Lee-01 7c51297
refactor: 변수명 변경
Sehee-Lee-01 ee9b045
refactor: 줄바꿈 변경
Sehee-Lee-01 4cccc96
refactor: 변수명 변경
Sehee-Lee-01 50258a8
chore: assertJ 추가
Sehee-Lee-01 ed9dc3e
refactor: ANSWER_LENGTH 사용 위치 변경
Sehee-Lee-01 1e496f0
Revert "refactor: ANSWER_LENGTH 사용 위치 변경"
Sehee-Lee-01 dde358a
test: test stub 생성
Sehee-Lee-01 b3205ce
refactor: 예외 메시지 상수화
Sehee-Lee-01 bfb2c6d
refactor: 메시지 상수화
Sehee-Lee-01 471037a
refactor: 숫자 답 길이 고정
Sehee-Lee-01 8c493ec
rename: 클래스명 변경
Sehee-Lee-01 25ff786
test: AnswerTest 작성
Sehee-Lee-01 018a934
test: GamePlayerTest 작성
Sehee-Lee-01 5c8ea1d
test: RandomNumberMakerTest 작성
Sehee-Lee-01 f2d13da
refactor: hint 결과 관련 string 상수화
Sehee-Lee-01 6090d58
refactor: 불필요한 Printer 메서드 삭제
Sehee-Lee-01 7e89470
rename: testutil 리패키징
Sehee-Lee-01 1348dc9
test: AnswerSourceProvider 생성
Sehee-Lee-01 c1d827d
chore: .gitignore에서 .idea 제외
Sehee-Lee-01 a9ff50e
chore: .gitignore에서 캐시 삭제
Sehee-Lee-01 14981fd
fix: record를 일반 클래스로 변경
Sehee-Lee-01 c8000eb
fix: GamePlayerMessage final 클래스로 변경
Sehee-Lee-01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor: hint 결과 관련 string 상수화
- Loading branch information
commit f2d13da8028335a519806948b425bd84b647eace
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -3,6 +3,9 @@ | |
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | ||
| import static sehee.util.constant.NumberBaseballGameConstant.ANSWER_LENGTH; | ||
| import static sehee.util.constant.NumberBaseballGameConstant.BALL; | ||
| import static sehee.util.constant.NumberBaseballGameConstant.NOTHING; | ||
| import static sehee.util.constant.NumberBaseballGameConstant.STRIKE; | ||
| import static sehee.util.constant.NumberBaseballGameMessage.ANSWER_LENGTH_EXCEPTION_MESSAGE; | ||
| import static sehee.util.constant.NumberBaseballGameMessage.DUPLICATED_EXCEPTION_MESSAGE; | ||
|
|
||
|
|
@@ -11,7 +14,9 @@ | |
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Nested; | ||
| import org.junit.jupiter.api.Test; | ||
| import sehee.stub.NumberMakerStub; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
| import sehee.testutil.stub.NumberMakerStub; | ||
|
|
||
| class AnswerTest { | ||
|
|
||
|
|
@@ -91,17 +96,85 @@ void failInputMakeByDuplicated() { | |
| @Nested | ||
| class MatchTest { | ||
|
|
||
| @BeforeEach | ||
| void setup() { | ||
| @Test | ||
| @DisplayName("컴퓨터 설정값과 사용자 입력값이 모두 같은 경우 3스트라이크 결과가 나온다.") | ||
| void successMatchThreeStrike() { | ||
| // given | ||
| int[] numbers = new int[] {1, 2, 3}; | ||
| Answer computerAnswer = answerFactory.make(numbers); | ||
| Answer userAnswer = answerFactory.make(numbers); | ||
|
|
||
| // when | ||
| Hint matchResult = computerAnswer.match(userAnswer); | ||
|
|
||
| // then | ||
| assertThat(matchResult.isThreeStrike()).isTrue(); | ||
| assertThat(matchResult.toString()).isEqualTo(ANSWER_LENGTH + STRIKE); | ||
| } | ||
|
|
||
| @ParameterizedTest(name = "[{index}] {0}개의 숫자가 같은 위치에서 값이 일치하는 경우({0}스트라이크)") | ||
| @MethodSource("sehee.testutil.source.AnswerSourceProvider#provideStrikeCase") | ||
| @DisplayName("같은 위치의 숫자값이 같은 경우를 합한 값이 스트라이크이다.") | ||
| void successMatchStrike(int strikeCount, int[] computerNumbers, int[] userNumbers) { | ||
| // given | ||
| Answer computerAnswer = answerFactory.make(computerNumbers); | ||
| Answer userAnswer = answerFactory.make(userNumbers); | ||
|
|
||
| // when | ||
| Hint matchResult = computerAnswer.match(userAnswer); | ||
|
|
||
| // then | ||
| assertThat(matchResult.toString()).isEqualTo(strikeCount + STRIKE); | ||
| } | ||
|
|
||
| @ParameterizedTest(name = "[{index}] {0}개의 숫자가 다른 위치에서 값이 일치하는 경우({0}볼)") | ||
| @MethodSource("sehee.testutil.source.AnswerSourceProvider#provideBallCase") | ||
| @DisplayName("다른 위치의 숫자값이 같은 경우를 합한 값이 볼이다.") | ||
| void successMatchBall(int ballCount, int[] computerNumbers, int[] userNumbers) { | ||
| // given | ||
| Answer computerAnswer = answerFactory.make(computerNumbers); | ||
| Answer userAnswer = answerFactory.make(userNumbers); | ||
|
|
||
| // when | ||
| Hint matchResult = computerAnswer.match(userAnswer); | ||
|
|
||
| // then | ||
| assertThat(matchResult.isThreeStrike()).isFalse(); | ||
| assertThat(matchResult.toString()).isEqualTo(ballCount + BALL); | ||
| } | ||
|
|
||
| @ParameterizedTest(name = "[{index}] {0}볼 {1}스트라이크인 경우") | ||
| @MethodSource("sehee.testutil.source.AnswerSourceProvider#provideBallAndStrikeCase") | ||
| @DisplayName("볼과 스트라이크가 동시에 발견될 수 있다.") | ||
| void successMatchBall(int ballCount, int strikeCount, int[] computerNumbers, int[] userNumbers) { | ||
| // given | ||
| Answer computerAnswer = answerFactory.make(computerNumbers); | ||
| Answer userAnswer = answerFactory.make(userNumbers); | ||
|
|
||
| // when | ||
| Hint matchResult = computerAnswer.match(userAnswer); | ||
|
|
||
| // then | ||
| assertThat(matchResult.isThreeStrike()).isFalse(); | ||
| assertThat(matchResult.toString()).isEqualTo(ballCount + BALL + " " + strikeCount + STRIKE); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("") | ||
| void successMatchByThreeStrike() { | ||
| @DisplayName("컴퓨터 설정값과 사용자 입력값이 다른 경우 낫싱 결과가 나온다.") | ||
| void successMatchNothing() { | ||
| // given | ||
| int[] computerNumbers = new int[] {1, 2, 3}; | ||
| Answer computerAnswer = answerFactory.make(computerNumbers); | ||
|
|
||
| int[] userNumbers = new int[] {4, 5, 6}; | ||
| Answer userAnswer = answerFactory.make(userNumbers); | ||
|
|
||
| // when | ||
| Hint matchResult = computerAnswer.match(userAnswer); | ||
|
|
||
| // then | ||
| assertThat(matchResult.isThreeStrike()).isFalse(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. assertFalse()로 간략화할 수 있을 것 같아요! |
||
| assertThat(matchResult.toString()).isEqualTo(NOTHING); | ||
| } | ||
|
|
||
| } | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package sehee.game; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.assertThatNoException; | ||
| import static sehee.util.constant.NumberBaseballGameMessage.GAME_OVER_MESSAGE; | ||
|
|
||
| import org.assertj.core.api.ThrowableAssert; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import sehee.answer.AnswerFactory; | ||
| import sehee.exception.ExceptionHandler; | ||
| import sehee.stub.NumberMakerStub; | ||
| import sehee.stub.PrinterStub; | ||
| import sehee.stub.ReaderStub; | ||
|
|
||
| class NumberBaseballGameTest { | ||
|
|
||
| private NumberBaseballGame game; | ||
| private ReaderStub reader; | ||
| private PrinterStub printer; | ||
| private NumberMakerStub numberMaker; | ||
|
|
||
| @BeforeEach | ||
| void setup() { | ||
| // IO | ||
| reader = new ReaderStub(); | ||
| printer = new PrinterStub(); | ||
|
|
||
| // Exception | ||
| ExceptionHandler exceptionHandler = new ExceptionHandler(printer); | ||
|
|
||
| // Set Game | ||
| numberMaker = new NumberMakerStub(); | ||
| AnswerFactory answerFactory = new AnswerFactory(numberMaker); | ||
| game = new NumberBaseballGame(reader, printer, answerFactory, exceptionHandler); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("숫자 야구 게임을 시작하고 컴퓨터 설정값과 입력값이 일치하는 경우 정상적으로 종료된다.") | ||
| void successGameOver() { | ||
| // given | ||
| int[] answerNumber = new int[] {1, 2, 3}; | ||
| numberMaker.setNumbers(answerNumber); // 컴퓨터 설정값 | ||
| reader.setNumbers(answerNumber); // 사용자 입력값 | ||
|
|
||
| // when | ||
| ThrowableAssert.ThrowingCallable gameOver = () -> game.play(); | ||
|
|
||
| // then | ||
| assertThatNoException().isThrownBy(gameOver); | ||
| assertThat(printer.getLatestMessage()).isEqualTo(GAME_OVER_MESSAGE); | ||
| } | ||
|
|
||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.