Beispiel #1
0
        public bool Create(Person entity)
        {
            Random rnd = new Random();

            entity.Id = Convert.ToString(rnd.Next(10000, 99999));

            var personas = _personRepository.GetAll().ToList().SkipWhile(s => s.Id == entity.Id); //Evita a si mismo

            if (entity.Rol == "Catador")
            {
                if (personBll.ValidateCatador(entity).StartsWith("Error"))
                {
                    return(false);
                }
            }

            if (personBll.ValidatePersona(entity, personas).StartsWith("Error"))
            {
                return(false);
            }

            try
            {
                _personRepository.Add(entity);
                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        public void Persona_Nick_Incorrecto()
        {
            Person entity = new Person()
            {
                Id        = "1234",
                Cedula    = "1065",
                Nombre    = "Oscar",
                Apellido  = "Lozano",
                Telefono  = "5858585",
                Correo    = "*****@*****.**",
                Direccion = "Av. Siempre Viva",
                Nick      = "Osc",
                Clave     = "23456789",
                Permiso   = false,
                Rol       = "Catador",
            };
            //Act-> Actuar
            string resultado = personaBll.ValidateCatador(entity);

            //Assert->Afirmar
            Assert.AreEqual("Error. Nick necesita entre 5 a 30 caracteres", resultado);
        }