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)); } }
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"); }
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"); }
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)); }
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"); }
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."); }
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>()); }
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)); } }