示例#1
0
        public void GetInexistentCountry()
        {
            //Prueba el comportamiento cuando no existe país.
            CountryBLL countryBll = new CountryBLL();
            ResultBM   result     = countryBll.GetCountry("XX");
            CountryBM  country    = result.GetValue <CountryBM>();

            Assert.IsNull(country, "El país con iso2 XX no debería existir");
        }
示例#2
0
        public void GetCountry()
        {
            //Prueba que pueda recuperar el país pasado por parámetro.
            CountryBLL countryBll = new CountryBLL();
            ResultBM   result     = countryBll.GetCountry("AR");
            CountryBM  country    = result.GetValue <CountryBM>();

            Assert.IsNotNull(country, "Debería haber recuperado el país argentina");
            Assert.AreEqual(country.iso2, "AR", "Debería existir AR");
            Assert.AreEqual(country.Name, "Argentina", "Debería ser Argentina");
        }
示例#3
0
 private Country ConvertToDM(CountryBM model)
 {
     return(new Country
     {
         CountryId = model.CountryId,
         Name = model.Name,
         CreatedBy = model.CreatedBy,
         CreationDate = model.CreationDate,
         ModifiedBy = model.ModifiedBy,
         ModificationDate = model.ModificationDate
     });
 }
示例#4
0
        private ResultBM create_invalid_person(PersonBM personBm)
        {
            CountryBLL countryBll = new CountryBLL();
            ResultBM   result     = countryBll.GetCountry("AR");
            CountryBM  countryBm  = result.GetValue <CountryBM>();
            AddressBLL addressBll = new AddressBLL();
            AddressBM  addressBm  = new AddressBM("Calle test", 999, "Departamento", "Barrio", "Esta es una dirección creada mediante test", countryBm);

            PersonBLL personBll = new PersonBLL();

            return(personBll.SavePerson(personBm));
        }
示例#5
0
        public void CreateAddress()
        {
            //Prueba la creación de una dirección
            CountryBLL countryBll = new CountryBLL();
            ResultBM   result     = countryBll.GetCountry("AR");
            CountryBM  countryBm  = result.GetValue <CountryBM>();
            AddressBLL addressBll = new AddressBLL();
            AddressBM  addressBm  = new AddressBM("Calle test", 999, "Departamento", "Barrio", "Esta es una dirección creada mediante test", countryBm);

            ResultBM addressResult = addressBll.SaveAddress(addressBm);

            Assert.IsTrue(addressResult.IsValid(), "Debería haberse guardado");
        }
示例#6
0
        public void CreateAddressFailsNumber()
        {
            //Prueba la validación del número
            CountryBLL countryBll = new CountryBLL();
            ResultBM   result     = countryBll.GetCountry("AR");
            CountryBM  countryBm  = result.GetValue <CountryBM>();
            AddressBLL addressBll = new AddressBLL();
            AddressBM  addressBm  = new AddressBM("Calle test", -1, "Departamento", "Barrio", "Esta es una dirección creada mediante test", countryBm);

            ResultBM addressResult = addressBll.SaveAddress(addressBm);

            Assert.IsTrue(addressResult.IsCurrentError(ResultBM.Type.INCOMPLETE_FIELDS), "No debería haber sido válido.");
            Assert.IsTrue(addressResult.description.Contains("calle"), "No debería haber sido válido.");
        }
示例#7
0
        private PersonBM create_person()
        {
            CountryBLL countryBll = new CountryBLL();
            ResultBM   result     = countryBll.GetCountry("AR");
            CountryBM  countryBm  = result.GetValue <CountryBM>();
            AddressBLL addressBll = new AddressBLL();
            AddressBM  addressBm  = new AddressBM("Calle test", 999, "Departamento", "Barrio", "Esta es una dirección creada mediante test", countryBm);

            PersonBLL personBll  = new PersonBLL();
            PersonBM  personBm   = new PersonBM("Name test", "lastname test", DateTime.Now, "mail", "1553489636", 'M', 29192646, addressBm);
            ResultBM  saveResult = personBll.SavePerson(personBm);

            Assert.IsTrue(saveResult.IsValid(), "La persona debería haberse creado");
            return(saveResult.GetValue <PersonBM>());
        }
示例#8
0
        /// <summary>
        /// Devuelve el país para el iso2 requerido
        /// </summary>
        /// <param name="iso2"></param>
        /// <returns></returns>
        public ResultBM GetCountry(string iso2)
        {
            try {
                CountryDAL countryDal = new CountryDAL();
                CountryDTO countryDto = countryDal.GetCountry(iso2);
                CountryBM  countryBm  = null;

                if (countryDto != null)
                {
                    countryBm = new CountryBM(countryDto);
                }

                return(new ResultBM(ResultBM.Type.OK, "Operación exitosa.", countryBm));
            }
            catch (Exception exception) {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("RETRIEVING_ERROR") + " " + exception.Message, exception));
            }
        }
示例#9
0
 public void Update(CountryBM model)
 {
     uow.CountryRepository.Update(ConvertToDM(model));
     uow.Save();
 }
示例#10
0
 public void Create(CountryBM model)
 {
     uow.CountryRepository.Add(ConvertToDM(model));
     uow.Save();
 }