示例#1
0
        public void TestAlreadyExists()
        {
            var userFactory    = new InMemoryUserFactory();
            var userRepository = new InMemoryUserRepository();
            var userService    = new UserService(userRepository);
            var interactor     = new UserRegisterInteractor(userFactory, userRepository, userService);

            var userName = "******";

            userRepository.Save(new User(
                                    new UserId("test-id"),
                                    new UserName(userName),
                                    UserType.Normal
                                    ));

            bool exceptionOccured = false;

            try
            {
                var command = new UserRegisterInputData(userName);
                interactor.Handle(command);
            }
            catch
            {
                exceptionOccured = true;
            }

            Assert.IsTrue(exceptionOccured);
        }
示例#2
0
        public void TestSuccessMaxUserName()
        {
            var userFactory    = new InMemoryUserFactory();
            var userRepository = new InMemoryUserRepository();
            var userService    = new UserService(userRepository);
            var interactor     = new UserRegisterInteractor(userFactory, userRepository, userService);

            // 사용자명의 최장 길이(20글자)를 만족하는 사용자 등록이 정상적으로 완료되는지 확인
            var userName             = "******";
            var maxUserNameInputData = new UserRegisterInputData(userName);

            interactor.Handle(maxUserNameInputData);

            // 사용자 정보가 잘 저장됐는지 확인
            var createdUserName = new UserName(userName);
            var maxUserNameUser = userRepository.Find(createdUserName);

            Assert.IsNotNull(maxUserNameUser);
        }
示例#3
0
        public void TestSuccessMaxUserName()
        {
            var userFactory    = new InMemoryUserFactory();
            var userRepository = new InMemoryUserRepository();
            var userService    = new UserService(userRepository);
            var interactor     = new UserRegisterInteractor(userFactory, userRepository, userService);

            // 最長のユーザ名(20文字)のユーザが正常に生成できるか
            var userName             = "******";
            var maxUserNameInputData = new UserRegisterInputData(userName);

            interactor.Handle(maxUserNameInputData);

            // ユーザが正しく保存されているか
            var createdUserName = new UserName(userName);
            var maxUserNameUser = userRepository.Find(createdUserName);

            Assert.IsNotNull(maxUserNameUser);
        }
示例#4
0
        public void TestSuccessMinUserName()
        {
            var userFactory    = new InMemoryUserFactory();
            var userRepository = new InMemoryUserRepository();
            var userService    = new UserService(userRepository);
            var interactor     = new UserRegisterInteractor(userFactory, userRepository, userService);

            // 사용자명의 최소 길이(3글자)를 만족하는 사용자 등록이 정상적으로 완료되는지 확인
            var userName             = "******";
            var minUserNameInputData = new UserRegisterInputData(userName);
            var outputData           = interactor.Handle(minUserNameInputData);

            Assert.IsNotNull(outputData.CreatedUserId);

            // 사용자 정보가 잘 저장됐는지 확인
            var createdUserName = new UserName(userName);
            var createdUser     = userRepository.Find(createdUserName);

            Assert.IsNotNull(createdUser);
        }
示例#5
0
        public void TestSuccessMinUserName()
        {
            var userFactory    = new InMemoryUserFactory();
            var userRepository = new InMemoryUserRepository();
            var userService    = new UserService(userRepository);
            var interactor     = new UserRegisterInteractor(userFactory, userRepository, userService);

            // 最短のユーザ名(3文字)のユーザが正常に生成できるか
            var userName             = "******";
            var minUserNameInputData = new UserRegisterInputData(userName);
            var outputData           = interactor.Handle(minUserNameInputData);

            Assert.IsNotNull(outputData.CreatedUserId);

            // ユーザが正しく保存されているか
            var createdUserName = new UserName(userName);
            var createdUser     = userRepository.Find(createdUserName);

            Assert.IsNotNull(createdUser);
        }
示例#6
0
        public void TestInvalidUserNameLengthMax()
        {
            var userFactory    = new InMemoryUserFactory();
            var userRepository = new InMemoryUserRepository();
            var userService    = new UserService(userRepository);
            var interactor     = new UserRegisterInteractor(userFactory, userRepository, userService);

            bool exceptionOccured = false;

            try
            {
                var command = new UserRegisterInputData("123456789012345678901");
                interactor.Handle(command);
            }
            catch
            {
                exceptionOccured = true;
            }

            Assert.IsTrue(exceptionOccured);
        }