public ActionResult Delete(int id)
        {
            CountryBLL objCountryBLL = new CountryBLL();
            var        country       = objCountryBLL.GetCountry(id);

            return(View(country));
        }
 public ActionResult Input(string id = "")
 {
     try
     {
         if (string.IsNullOrEmpty(id))
         {
             ViewBag.Title = "Create new Country";
             Country newSupplier = new Country()
             {
                 CountryID = 0
             };
             return(View(newSupplier));
         }
         else
         {
             ViewBag.Title = "Edit a Country";
             Country editCountry = CountryBLL.GetCountry(Convert.ToInt32(id));
             if (editCountry == null)
             {
                 return(RedirectToAction("Index"));
             }
             return(View(editCountry));
         }
     }
     catch (Exception ex)
     {
         return(Content(ex.Message + ":" + ex.StackTrace));
     }
 }
示例#3
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");
        }
示例#4
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");
        }
示例#5
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));
        }
示例#6
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");
        }
示例#7
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.");
        }
示例#8
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>());
        }
示例#9
0
 public ActionResult Input(string id = "")
 {
     if (string.IsNullOrEmpty(id))
     {
         ViewBag.Title = "Create new Country";
         Country newCategory = new Country()
         {
             CountryID = 0
         };
         return(View(newCategory));
     }
     else
     {
         ViewBag.Title = "Edit a Country";
         Country editCountry = CountryBLL.GetCountry(Convert.ToInt32(id));
         if (editCountry == null)
         {
             return(RedirectToAction("Index"));
         }
         return(View(editCountry));
     }
 }