Exemplo n.º 1
0
        public void Update(EnderecoDTO obj)
        {
            EnderecoValidation enderecoValidation = new EnderecoValidation();

            if (enderecoValidation.ValidarLogradouro(obj.Logradouro))
            {
                throw new System.ArgumentException("Campo logradouro é obrigatório ou tem mais de 50 caracteres", "Erro cliente");
            }
            if (enderecoValidation.ValidarEstado(obj.Estado))
            {
                throw new System.ArgumentException("O campo estado é obrigatório ou tem mais de 40 caracteres", "Erro cliente");
            }
            if (enderecoValidation.ValidarCidade(obj.Cidade))
            {
                throw new System.ArgumentException("O campo cidade é obrigatório ou tem mais de 40 caracteres", "Erro cliente");
            }
            if (enderecoValidation.ValidarBairro(obj.Bairro))
            {
                throw new System.ArgumentException("O campo bairro é obrigatório ou tem mais de 40 caracteres", "Erro cliente");
            }

            var objEndereco = _enderecoMapper.MapperToEntity(obj);

            _enderecoService.Update(objEndereco);
        }
Exemplo n.º 2
0
        public void Test_BairroObrigatorio()
        {
            Endereco enderecoSemBairro = new Endereco()
            {
                Bairro = ""
            };
            Endereco enderecoComBairro = new Endereco()
            {
                Bairro = "Avenida Central"
            };
            EnderecoValidation enderecoValidation = new EnderecoValidation();

            Assert.IsTrue(enderecoValidation.ValidarBairro(enderecoSemBairro.Bairro));
        }
Exemplo n.º 3
0
        public void Test_BairroMaiorQue40Caracteres()
        {
            Endereco enderecoSemBairroMaiorQue50Caracteres = new Endereco()
            {
                Bairro = "Avenida CentralAvenida CentralAvenida CentralAvenida CentralAvenida CentralAvenida Central"
            };
            Endereco bairroMenorQue50Caracteres = new Endereco()
            {
                Bairro = "Avenida Central"
            };
            EnderecoValidation EnderecoValidation = new EnderecoValidation();

            Assert.IsTrue(EnderecoValidation.ValidarBairro(enderecoSemBairroMaiorQue50Caracteres.Bairro));
            //Assert.IsFalse(EnderecoValidation.ValidarBairro(enderecoSemBairroMaiorQue50Caracteres));
        }