public void WhenValidCNPJWithMaskThenShouldReturnTrue(string cnpj) { //Act bool result = CNPJUtil.ValidateCNPJ(cnpj); //Assert Assert.IsTrue(result); }
public void WhenOnlyMaskCNPJThenShouldReturnFalse() { //Act bool result = CNPJUtil.ValidateCNPJ("..-/"); //Assert Assert.IsFalse(result); }
public void WhenEmptyCNPJThenShouldReturnFalse() { //Act bool result = CNPJUtil.ValidateCNPJ(string.Empty); //Assert Assert.IsFalse(result); }
public NotificationResult Atualizar(Fornecedor entidade) { var notificationResult = new NotificationResult(); try { if (EmailUtil.ValidarEmail(entidade.Email) == false) { notificationResult.Add(new NotificationError("Email Inválido!", NotificationErrorType.USER)); } if (CNPJUtil.ValidarCNPJ(entidade.CNPJ) == false) { notificationResult.Add(new NotificationError("CNPJ Do Fornecedor Inválido", NotificationErrorType.USER)); } if (string.IsNullOrEmpty(entidade.TelefoneFixo)) { notificationResult.Add(new NotificationError("Telefone Inválido", NotificationErrorType.USER)); } if (string.IsNullOrEmpty(entidade.Nome)) { notificationResult.Add(new NotificationError("Nome Do Fornecedor Inválido", NotificationErrorType.USER)); } if (entidade.idFornecedor <= 0) { return(notificationResult.Add(new NotificationError("Código do Fornecedor Inválido!"))); } if (string.IsNullOrEmpty(entidade.EnderecoImagem)) { notificationResult.Add(new NotificationError("URL da Imagem Inválida ou Não Suportada!", NotificationErrorType.USER)); } if (notificationResult.IsValid) { _fornecedorRepositorio.Atualizar(entidade); notificationResult.Add("Fornecedor Atualizado com sucesso."); } return(notificationResult); } catch (Exception ex) { return(notificationResult.Add(new NotificationError(ex.Message))); } }
public NotificationResult Salvar(Vendedor entidade) { var notificationResult = new NotificationResult(); try { if (EmailUtil.ValidarEmail(entidade.Email) == false) { notificationResult.Add(new NotificationError("Email Inválido!", NotificationErrorType.USER)); } if (string.IsNullOrEmpty(entidade.TelefoneFixo)) { notificationResult.Add(new NotificationError("Telefone Inválido", NotificationErrorType.USER)); } if (string.IsNullOrEmpty(entidade.Nome)) { notificationResult.Add(new NotificationError("Nome do Vendedor Inválido!")); } if (CNPJUtil.ValidarCNPJ(entidade.CNPJ) == false) { notificationResult.Add(new NotificationError("CNPJ Do Vendedor Inválido", NotificationErrorType.USER)); } if (string.IsNullOrEmpty(entidade.EnderecoImagem)) { notificationResult.Add(new NotificationError("URL da Imagem Inválida ou Não Suportada!", NotificationErrorType.USER)); } if (notificationResult.IsValid) { _vendedorRepositorio.Adicionar(entidade); notificationResult.Add("Vendedor Cadastrado com sucesso."); } notificationResult.Result = entidade; return(notificationResult); } catch (Exception ex) { return(notificationResult.Add(new NotificationError(ex.Message))); } }
public void WhenNullCNPJThenShouldThrowArgumentNullException() { //Assert Assert.ThrowsException <ArgumentNullException>(() => CNPJUtil.ValidateCNPJ(null)); }