public void VaccineUpdateSuccessFive() { IVaccineStorage vaccineStorage = new VaccineStorage(); Vaccine myVaccine = CreateVaccineForTest( "狂犬疫苗1", "处方1", getManufacturersIDtwo(), "68.00", "45"); Vaccine createdVaccine = vaccineStorage.CreateVaccine(myVaccine); Assert.AreNotEqual( 0, createdVaccine.VaccineID, string.Format("Could not create Vaccine:{0}", createdVaccine.VaccineID)); myVaccine.VaccineQuantity = Convert.ToInt32("60"); vaccineStorage.UpdateVaccine(myVaccine); Vaccine updatedVaccine = vaccineStorage.ReadVaccine( createdVaccine.VaccineID); AssertVaccineItemEqual(myVaccine, updatedVaccine); }
private void btnModfiy_Click(object sender, EventArgs e) { IVaccineStorage vaccineStorage = new VaccineStorage(); Vaccine vaccine = new Vaccine(); if (textVaccineName.Text.Trim() == "" || textVaccineSort.Text.Trim() == "" || cmbManufacturersName.Text.Trim() == "" || textVaccinePrice.Text.Trim() == "" || textVaccineQuantity.Text.Trim() == "") { MessageBox.Show("请双击需要修改的记录!"); } else { vaccine.VaccineName = textVaccineName.Text; vaccine.VaccineSort = textVaccineSort.Text; vaccine.ManufacturersID = Convert.ToInt32(cmbManufacturersName.SelectedValue.ToString()); vaccine.VaccinePrice = Convert.ToDecimal(textVaccinePrice.Text.Trim()); vaccine.VaccineQuantity = Convert.ToInt32(textVaccineQuantity.Text.Trim()); vaccine.VaccineID = Convert.ToInt32(dgvVaccine[0, dgvVaccine.CurrentCell.RowIndex].Value.ToString()); vaccineStorage.UpdateVaccine(vaccine); MessageBox.Show("更新成功!"); textVaccineName.Text = ""; textVaccineSort.Text = ""; cmbManufacturersName.Text = ""; textVaccinePrice.Text = ""; textVaccineQuantity.Text = ""; } }
public void VaccineUpdateFailureVaccineIdArgumentException() { IVaccineStorage vaccineStorage = new VaccineStorage(); Vaccine myVaccine = CreateVaccineForTest( "狂犬疫苗1", "处方1", getManufacturersIDtwo(), "68.00", "45"); vaccineStorage.CreateVaccine(myVaccine); myVaccine.VaccineID = int.MaxValue; vaccineStorage.UpdateVaccine(myVaccine); }
public void VaccineUpdateFailureVaccineArgumentNullException() { IVaccineStorage vaccineStorage = new VaccineStorage(); vaccineStorage.UpdateVaccine(null); }