Skip to content

Commit

Permalink
fix: lastStatus 값 반환 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
miseongk committed Oct 8, 2024
1 parent 95678fb commit 472da2b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Letter(
otherLetter.isShareContact != null -> LetterLastStatus.CONTACT_SHARED_BY_OTHER
this.isShareImage != null && otherLetter.isShareImage == null -> LetterLastStatus.PHOTO_SHARED_BY_ME_ONLY
otherLetter.isShareImage != null -> LetterLastStatus.PHOTO_SHARED_BY_OTHER
this.letters.isEmpty() && otherLetter.letters.isEmpty() -> LetterLastStatus.NO_ANSWER_FROM_BOTH
this.findAnsweredSize() == 0 && otherLetter.findAnsweredSize() == 0 -> LetterLastStatus.NO_ANSWER_FROM_BOTH
this.findAnsweredSize() > otherLetter.findAnsweredSize() -> LetterLastStatus.ANSWER_FROM_ME_ONLY
otherLetter.findAnsweredSize() >= this.findAnsweredSize() -> LetterLastStatus.ANSWER_FROM_OTHER
else -> LetterLastStatus.NO_ANSWER_FROM_BOTH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ class LetterTest {
targetUser = TARGET_USER, sourceUser = SOURCE_USER, likeMessage = LikeMessage("hi"),
bottleStatus = BottleStatus.SENT, pingPongStatus = PingPongStatus.ACTIVE
);
private val MY_LETTERS = listOf(
LetterQuestionAndAnswer(question = "question1"),
LetterQuestionAndAnswer(question = "question2"),
LetterQuestionAndAnswer(question = "question3")
)
private val OTHER_LETTERS = listOf(
LetterQuestionAndAnswer(question = "question1"),
LetterQuestionAndAnswer(question = "question2"),
LetterQuestionAndAnswer(question = "question3")
)
private val MY_LETTERS = listOf(LetterQuestionAndAnswer(question = "question1"))
private val OTHER_LETTERS = listOf(LetterQuestionAndAnswer(question = "question1"))
}

@Nested
Expand All @@ -45,8 +37,20 @@ class LetterTest {

@Test
fun `내가 문답을 작성했을 경우`() {
val myLetter = Letter(bottle = PING_PONG_BOTTLE, user = TARGET_USER, letters = MY_LETTERS)
val otherLetter = Letter(bottle = PING_PONG_BOTTLE, user = SOURCE_USER, letters = OTHER_LETTERS)
val myLetter = Letter(
bottle = PING_PONG_BOTTLE, user = TARGET_USER, letters = listOf(
LetterQuestionAndAnswer(question = "question1"),
LetterQuestionAndAnswer(question = "question2"),
LetterQuestionAndAnswer(question = "question3")
)
)
val otherLetter = Letter(
bottle = PING_PONG_BOTTLE, user = SOURCE_USER, letters = listOf(
LetterQuestionAndAnswer(question = "question1"),
LetterQuestionAndAnswer(question = "question2"),
LetterQuestionAndAnswer(question = "question3")
)
)
myLetter.registerAnswer(1, "답변")

val lastStatus = myLetter.findLastStatusWithOtherLetter(otherLetter)
Expand All @@ -56,8 +60,20 @@ class LetterTest {

@Test
fun `상대방이 문답을 작성했을 경우`() {
val myLetter = Letter(bottle = PING_PONG_BOTTLE, user = TARGET_USER, letters = MY_LETTERS)
val otherLetter = Letter(bottle = PING_PONG_BOTTLE, user = SOURCE_USER, letters = OTHER_LETTERS)
val myLetter = Letter(
bottle = PING_PONG_BOTTLE, user = TARGET_USER, letters = listOf(
LetterQuestionAndAnswer(question = "question1"),
LetterQuestionAndAnswer(question = "question2"),
LetterQuestionAndAnswer(question = "question3")
)
)
val otherLetter = Letter(
bottle = PING_PONG_BOTTLE, user = SOURCE_USER, letters = listOf(
LetterQuestionAndAnswer(question = "question1"),
LetterQuestionAndAnswer(question = "question2"),
LetterQuestionAndAnswer(question = "question3")
)
)
otherLetter.registerAnswer(1, "답변")

val lastStatus = myLetter.findLastStatusWithOtherLetter(otherLetter)
Expand Down

0 comments on commit 472da2b

Please sign in to comment.