-
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.
- Loading branch information
Showing
1 changed file
with
12 additions
and
81 deletions.
There are no files selected for viewing
93 changes: 12 additions & 81 deletions
93
domain/src/test/java/org/depromeet/spot/domain/media/MediaTest.java
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,102 +1,33 @@ | ||
package org.depromeet.spot.domain.media; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.List; | ||
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; | ||
|
||
import org.depromeet.spot.common.exception.media.MediaException.InvalidMediaException; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.stubbing.Answer; | ||
|
||
class MediaTest { | ||
|
||
@Test | ||
public void 볼과_스트라이크가_모두_0일때_낫싱이다() { | ||
// given | ||
int ball = 0; | ||
int strike = 0; | ||
Result result = new Result(ball, strike); | ||
|
||
// when | ||
boolean isNothing = result.isNothing(); | ||
|
||
// then | ||
assertTrue(isNothing); | ||
} | ||
|
||
@Test | ||
public void 스트라이크가_3일때_쓰리스트라이크이다() { | ||
public void url이_없으면_미디어를_생성할_수_없다() { | ||
// given | ||
int ball = 0; | ||
int strike = 3; | ||
Result result = new Result(ball, strike); | ||
final String url = ""; | ||
final String fileName = "file"; | ||
|
||
// when | ||
boolean isThreeStrike = result.isThreeStrike(); | ||
|
||
// then | ||
assertTrue(isThreeStrike); | ||
} | ||
|
||
@Test | ||
public void 볼_카운트를_증가할_수_있다() { | ||
// given | ||
int ball = 0; | ||
int strike = 0; | ||
Result result = new Result(ball, strike); | ||
|
||
// when | ||
Result newResult = result.updateBall(); | ||
|
||
// then | ||
int updateBall = ball + 1; | ||
assertEquals(newResult.ball, updateBall); | ||
assertThatThrownBy(() -> new Media(url, fileName)) | ||
.isInstanceOf(InvalidMediaException.class); | ||
} | ||
|
||
@Test | ||
public void 스트라이크_카운트를_증가할_수_있다() { | ||
public void fileName이_없으면_미디어를_생성할_수_없다() { | ||
// given | ||
int ball = 0; | ||
int strike = 0; | ||
Result result = new Result(ball, strike); | ||
final String url = "url"; | ||
final String fileName = ""; | ||
|
||
// when | ||
Result newResult = result.updateStrike(); | ||
|
||
// then | ||
int updateStrike = strike + 1; | ||
assertEquals(newResult.strike, updateStrike); | ||
} | ||
|
||
@Test | ||
public void 다른_위치에_같은_수가_있다면_볼로_판정할_수_있다() { | ||
// given | ||
List<Number> computerValues = NumberFactory.createNumberList(1, 2, 3); | ||
List<Number> userValues = NumberFactory.createNumberList(2, 5, 6); | ||
Answer answer = new Answer(computerValues); | ||
UserInput userInput = new UserInput(userValues); | ||
int index = 0; | ||
|
||
// when | ||
boolean isBall = Result.isBall(answer, userInput, index); | ||
|
||
// then | ||
assertTrue(isBall); | ||
} | ||
|
||
@Test | ||
public void 같은_위치에_같은_수가_있다면_스트라이크로_판정할_수_있다() { | ||
// given | ||
List<Number> computerValues = NumberFactory.createNumberList(1, 2, 3); | ||
List<Number> userValues = NumberFactory.createNumberList(1, 5, 6); | ||
Answer answer = new Answer(computerValues); | ||
UserInput userInput = new UserInput(userValues); | ||
int index = 0; | ||
|
||
// when | ||
boolean isStrike = Result.isStrike(answer, userInput, index); | ||
|
||
// then | ||
assertTrue(isStrike); | ||
assertThatThrownBy(() -> new Media(url, fileName)) | ||
.isInstanceOf(InvalidMediaException.class); | ||
} | ||
} |