public async Task <User> RegisterPasswordAsync(string username, string email, string password)
        {
            if (!_regexValidator.IsValidEmail(email))
            {
                throw new InvalidEmailException();
            }

            if (!_regexValidator.IsValidPassword(password))
            {
                throw new InvalidPasswordException();
            }

            if (await _repository.ReadByUsernameAsync(username) != null)
            {
                throw new UsernameAlreadyExistsException();
            }

            if (await _repository.ReadByEmailAsync(email) != null)
            {
                throw new EmailAlreadyExistsException();
            }

            var salt           = _hashGenerator.Salt();
            var hashedPassword = _hashGenerator.Hash(password, salt);

            var user = await _repository.CreateAsync(
                new User
            {
                Username = username,
                Email    = email,
                Password = hashedPassword,
                Salt     = salt
            }
                );

            await _messageQueuePublisher.PublishMessageAsync(
                "Dwetter",
                "EmailMicroservice",
                "RegisterUser",
                JsonConvert.SerializeObject(new
            {
                email    = user.Email,
                username = user.Username
            }
                                            ));

            await _messageQueuePublisher.PublishMessageAsync(
                "Dwetter",
                "ProfileMicroservice",
                "RegisterUser",
                new
            {
                userId   = user.Id,
                username = user.Username
            }
                );

            return(user.WithoutSensitiveData());
        }
        public void Hash_AreNotEqual_ReturnsTrue()
        {
            // Arrange
            const string plainText = "test";
            var          salt      = _hashGenerator.Salt();

            // Act
            var result = _hashGenerator.Hash(plainText, salt);

            // Assert
            Assert.AreNotEqual(plainText, result);
        }