public void UpdateResponsible() { //Prueba la asigna un responsable a la donación //Creación del donador, un empleado (persona), la donación y el voluntario DonorBM donor = create_donor(); PersonBM personBm = create_person(); DonationStatusBM statusBm = get_status(1); DonationBLL donationBll = new DonationBLL(); DonationBM donationBm = new DonationBM(3, donor.donorId, statusBm, "Esta es una donación creada por un test."); ResultBM donationResult = donationBll.SaveDonation(donationBm); BranchBLL branchBll = new BranchBLL(); ResultBM branchResult = branchBll.GetBranch(1); VolunteerBLL volunteerBll = new VolunteerBLL(); VolunteerBM volunteerBm = new VolunteerBM(personBm, branchResult.GetValue <BranchBM>()); ResultBM volunterResult = volunteerBll.SaveVolunteer(volunteerBm); donationBm.volunteer = volunterResult.GetValue <VolunteerBM>(); ResultBM updateResult = donationBll.UpdateDonation(donationBm); Assert.IsTrue(updateResult.IsValid(), "La operación debería ser válida."); donationResult = donationBll.GetDonation(updateResult.GetValue <DonationBM>().id); Assert.IsTrue(donationResult.IsValid(), "La operación debería ser válida."); Assert.IsNotNull(donationResult.GetValue(), "Deería haber devuelto una donación."); Assert.IsNotNull(donationResult.GetValue <DonationBM>().volunteer, "Deería haber devuelto un voluntario."); Assert.AreEqual(donationResult.GetValue <DonationBM>().volunteer.volunteerId, volunterResult.GetValue <VolunteerBM>().volunteerId, "Debería ser el mismo voluntario."); }
public void CreateVolunteerFailsBranch() { //Crea un donador PersonBM personBm = create_person(); VolunteerBLL volunteerBll = new VolunteerBLL(); VolunteerBM volunteerBm = new VolunteerBM(personBm, null); ResultBM volunterResult = volunteerBll.SaveVolunteer(volunteerBm); Assert.IsFalse(volunterResult.IsValid(), "El voluntario debería existir."); Assert.IsTrue(volunterResult.IsCurrentError(ResultBM.Type.INCOMPLETE_FIELDS), "No debería haber sido válido."); Assert.IsNull(volunterResult.GetValue(), "No debería existir el voluntario."); }
public void CreateVolunteer() { //Crea un donador PersonBM personBm = create_person(); BranchBLL branchBll = new BranchBLL(); ResultBM brancResult = branchBll.GetBranch(1); Assert.IsTrue(brancResult.IsValid(), "El donador debería existir."); VolunteerBLL volunteerBll = new VolunteerBLL(); VolunteerBM volunteerBm = new VolunteerBM(personBm, brancResult.GetValue <BranchBM>()); ResultBM volunterResult = volunteerBll.SaveVolunteer(volunteerBm); Assert.IsTrue(volunterResult.IsValid(), "El donador debería existir."); Assert.IsNotNull(volunterResult.GetValue(), "Debería existir el voluntario."); Assert.IsTrue(volunterResult.GetValue <VolunteerBM>().id > 0, "Debería existir el voluntario."); }
private void DonationFrm_Load(object sender, EventArgs e) { try { dateArrival.CustomFormat = "dd/MM/yyyy hh:mm"; ChangeSize(); if (this.Entity != null && this.Entity.IsStored()) { MessageBox.Show("Está intentando editar una donación ya almacenada.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); groupBox1.Enabled = false; cmdAccept.Enabled = false; } //Traducciones SessionHelper.RegisterForTranslation(this, Codes.MNU_GE011); SessionHelper.RegisterForTranslation(cmdAccept, Codes.BTN_ACCEPT); SessionHelper.RegisterForTranslation(cmdClose, Codes.BTN_CLOSE); SessionHelper.RegisterForTranslation(lblLot, Codes.LBL_LOT); SessionHelper.RegisterForTranslation(lblArrival, Codes.LBL_ARRIVAL); SessionHelper.RegisterForTranslation(lblResponsible, Codes.LBL_RESPONSIBLE); SessionHelper.RegisterForTranslation(lblDonor, Codes.LBL_DONOR); SessionHelper.RegisterForTranslation(lblItems, Codes.LBL_ITEMS); SessionHelper.RegisterForTranslation(lblComment, Codes.LBL_OBSERVATION); SessionHelper.RegisterForTranslation(lblContact, Codes.LBL_CONTACT_INFO); SessionHelper.RegisterForTranslation(chkPickup, Codes.LBL_PICKUP); DonorBLL donorBll = new DonorBLL(); ResultBM donorResult = donorBll.GetDonors(); VolunteerBLL volunteerBll = new VolunteerBLL(); ResultBM volunteerResult = volunteerBll.GetVolunteers(); if (donorResult.IsValid()) { cmbDonor.SelectedIndexChanged -= cmbDonor_SelectedIndexChanged; cmbDonor.DataSource = donorResult.GetValue <List <DonorBM> >(); cmbDonor.DisplayMember = "FullName"; cmbDonor.SelectedIndexChanged += cmbDonor_SelectedIndexChanged; } else { MessageBox.Show(donorResult.description, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (volunteerResult.IsValid()) { //Se debe agregar un voluntario "Sin voluntario". List <VolunteerBM> volunteers = new List <VolunteerBM>(); VolunteerBM noVolunteer = new VolunteerBM(); noVolunteer.name = "-------------"; volunteers.Add(noVolunteer); volunteers.AddRange(volunteerResult.GetValue <List <VolunteerBM> >()); cmbVolunteer.DataSource = volunteers; cmbVolunteer.DisplayMember = "FullName"; } else { MessageBox.Show(volunteerResult.description, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (this.IsUpdate) { DonationBLL donationBll = new DonationBLL(); ResultBM donationResult = donationBll.GetDonation(this.Entity.id); if (donationResult.IsValid()) { //Estoy asumiento que se recuperó algo, más alla de que la operación fue exitosa this.Entity = donationResult.GetValue <DonationBM>(); lblLotId.Text = this.Entity.Lot.ToString(); dateArrival.Value = this.Entity.Arrival; chkPickup.Checked = this.Entity.IsToBeRetrieved(); numericItems.Value = this.Entity.Items; txtComment.Text = this.Entity.Comment; txtContact.Text = this.Entity.donor.GetContectInfo(); //Posicionar donador bool found = false; for (int i = 0; i < cmbDonor.Items.Count && !found; ++i) { found = ((DonorBM)cmbDonor.Items[i]).donorId == this.Entity.donor.donorId; if (found) { cmbDonor.SelectedIndex = i; } } found = false; for (int i = 0; i < cmbVolunteer.Items.Count && !found; ++i) { int id = this.Entity.volunteer == null ? 0 : this.Entity.volunteer.volunteerId; found = ((VolunteerBM)cmbVolunteer.Items[i]).volunteerId == id; if (found) { cmbVolunteer.SelectedIndex = i; } } } else { MessageBox.Show(donationResult.description, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { this.Entity = new DonationBM(); } } catch (Exception exception) { MessageBox.Show("Se ha producido el siguiente error: " + exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }