Skip to content

Commit

Permalink
[#70] feat: favoriting user 수 반환기능 구현 및 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyoungchoi95 committed Oct 29, 2021
1 parent 3856ffe commit eb492a9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public boolean isFavorite(User user) {
return favoritingUsers.contains(user);
}

public int favoritesCount() {
return favoritingUsers.size();
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.study.realworld.article.domain;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down Expand Up @@ -69,4 +70,22 @@ void falseTest() {

}

@Test
@DisplayName("현재 favoriting 중인 유저의 수를 확인할 수 있다.")
void favoritesCountTest() {

// given
Set<User> userSet = new HashSet<>();
userSet.add(user);
FavoritingUsers favoritingUsers = FavoritingUsers.of(userSet);

int expected = userSet.size();

// when
int result = favoritingUsers.favoritesCount();

// then
assertThat(result).isEqualTo(expected);
}

}

0 comments on commit eb492a9

Please sign in to comment.