Skip to content

Commit

Permalink
test(Media) : Media 테스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
EunjiShin committed Jul 9, 2024
1 parent a3ccf7f commit 596c9b6
Showing 1 changed file with 12 additions and 81 deletions.
93 changes: 12 additions & 81 deletions domain/src/test/java/org/depromeet/spot/domain/media/MediaTest.java
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);
}
}

0 comments on commit 596c9b6

Please sign in to comment.