Ejemplo n.º 1
0
        public async Task <User> Create(string username, string email, string password)
        {
            var encryptedPassword = passwordEncrypt.HashReturnSalt(password);
            var user = new User()
            {
                Username = username, Email = email, Salt = encryptedPassword.Item1, Password = encryptedPassword.Item2
            };

            await context.AddAsync(user);

            return(await context.SaveChangesAsync() > 0 ? user : null);
        }
        public void PasswordEncyrption_Hashed_ReturnsCorrectWhenChecked()
        {
            // Arrange
            var password = "******";
            var encrypt  = new PasswordEncryption();

            // Act
            var result = encrypt.HashReturnSalt(password);

            // Assert
            result.Item2.Should().Be(encrypt.Hash(password, result.Item1));
        }