Example #1
0
        public void Criptografar_DeveRetornarErro_QuandoTextoForMenorQuePermitido()
        {
            //Arrange
            var textoInvalido = string.Empty;

            //Act
            Action act = () => { SegurancaCommon.Criptografar(textoInvalido); };

            //Assert
            act.Should().Throw <ArgumentException>().WithMessage("Value does not fall within the expected range. (Parameter 'text')");
        }
Example #2
0
        public void Criptografar_DeveRetornarTextoCriptografado()
        {
            //Arrange
            var textoValido  = "awp9@sd&(&A";
            var cripografado = "672784197d165e7a2dca81d56bcc53532f2824c1d4cfa27e7fac9942f20f6b94";

            //Act
            var actual = SegurancaCommon.Criptografar(textoValido);

            //Assert
            actual.Should().Be(cripografado);
        }
Example #3
0
        public async Task <bool> CriarAsync(string usuario, string senha)
        {
            _context.Usuario.Add(new()
            {
                Usuario = usuario,
                Senha   = SegurancaCommon.Criptografar(senha)
            });

            await _context.SaveChangesAsync();

            return(true);
        }
Example #4
0
 public bool Existe(string usuario, string senha)
 {
     return(_context.Usuario.Any(u => u.Usuario == usuario && u.Senha == SegurancaCommon.Criptografar(senha)));
 }