-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAnswersTest.java
More file actions
35 lines (26 loc) · 1.21 KB
/
AnswersTest.java
File metadata and controls
35 lines (26 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package qna.domain;
import org.junit.jupiter.api.Test;
import qna.CannotDeleteException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
public class AnswersTest {
@Test
void validateItHasOtherAnswer_invalid() throws CannotDeleteException {
Answers answers = new Answers();
User otherUser = new User(11L, "applepickker", "abc112", "cho", "apple11@naver.com");
Answer answer = new Answer(otherUser, new Question(), "contents");
answers.add(answer);
User loginUser = new User(12L, "dal96k", "wjsdnals96", "woomin", "dal96k@hanmail.net");
assertThatThrownBy(() ->
answers.validateItHasOtherAnswer(loginUser))
.isInstanceOf(CannotDeleteException.class);
}
@Test
void validateItHasOtherAnswer_valid() throws CannotDeleteException {
Answers answers = new Answers();
User loginUser = new User(11L, "dal96k", "wjsdnals96", "woomin", "dal96k@hanmail.net");
Answer answer = new Answer(loginUser, new Question(), "contents");
answers.add(answer);
assertThat(answers.validateItHasOtherAnswer(loginUser)).isEqualTo(true);
}
}