-
Notifications
You must be signed in to change notification settings - Fork 8
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
2 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -15,18 +15,68 @@ | |
|
||
import codezap.global.exception.CodeZapException; | ||
import codezap.member.domain.Member; | ||
import codezap.member.repository.MemberRepository; | ||
import codezap.member.dto.LoginRequest; | ||
import codezap.member.dto.MemberDto; | ||
import codezap.member.dto.SignupRequest; | ||
import codezap.member.repository.FakeMemberRepository; | ||
import codezap.member.repository.MemberRepository; | ||
|
||
public class MemberServiceTest { | ||
|
||
private final MemberRepository memberRepository = new FakeMemberRepository(); | ||
private final AuthService authService = new AuthService(memberRepository); | ||
private final MemberService sut = new MemberService(memberRepository, authService); | ||
|
||
@Nested | ||
@DisplayName("이메일 중복 검사 테스트") | ||
class CheckEmail { | ||
|
||
@Test | ||
@DisplayName("이메일 중복 검사 통과: 사용가능한 이메일") | ||
void assertUniqueEmail() { | ||
var email = "[email protected]"; | ||
|
||
assertThatCode(() -> sut.assertUniqueEmail(email)) | ||
.doesNotThrowAnyException(); | ||
} | ||
|
||
@Test | ||
@DisplayName("이메일 중복 검사 실패: 중복된 이메일") | ||
void assertUniqueEmail_fail_duplicate() { | ||
var savedMember = new Member(1L, "[email protected]", "password", "zappy"); | ||
memberRepository.save(savedMember); | ||
|
||
assertThatThrownBy(() -> sut.assertUniqueEmail("[email protected]")) | ||
.isInstanceOf(CodeZapException.class) | ||
.hasMessage("이메일이 이미 존재합니다."); | ||
} | ||
} | ||
|
||
@Nested | ||
@DisplayName("사용자명 중복 검사 테스트") | ||
class CheckUsername { | ||
|
||
@Test | ||
@DisplayName("사용자명 중복 검사 통과: 사용가능한 사용자명") | ||
void assertUniqueUsername() { | ||
var username = "zappy"; | ||
|
||
assertThatCode(() -> sut.assertUniqueUsername(username)) | ||
.doesNotThrowAnyException(); | ||
} | ||
|
||
@Test | ||
@DisplayName("사용자명 중복 검사 실패: 중복된 사용자명") | ||
void assertUniqueUsername_fail_duplicate() { | ||
var savedMember = new Member(1L, "[email protected]", "password", "zappy"); | ||
memberRepository.save(savedMember); | ||
|
||
assertThatThrownBy(() -> sut.assertUniqueUsername("zappy")) | ||
.isInstanceOf(CodeZapException.class) | ||
.hasMessage("사용자명이 이미 존재합니다."); | ||
} | ||
} | ||
|
||
@Nested | ||
@DisplayName("회원가입 테스트") | ||
class SignupTest { | ||
|