public void InjectionMessageCreateSuccess() { IInjectionMessageStorage pInjectionMessageStorage = new InjectionMessageStorage(); IInjectorStorage pInjectorStorage = new InjectorStorage(); IVaccineStorage pVaccineStorage = new VaccineStorage(); int pgetInjectorID = getInjectorID(); int pgetVaccineID = getVaccineID(); InjectionMessage myInjectionMessage = CreateInjectionMessageForTest( pgetInjectorID, pInjectorStorage.ReadInjector(pgetInjectorID).InjectorName, pgetVaccineID, pVaccineStorage.ReadVaccine(pgetVaccineID).VaccineName, "某某人民医院", "2016-03-30", "陈医生"); InjectionMessage createdInjectionMessage = pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage); Assert.AreNotEqual( 0, createdInjectionMessage.InjectionMessageID, string.Format("Could not create InjectionMessage:{0}", createdInjectionMessage.InjectionMessageID)); AssertInjectionMessageItemEqual(myInjectionMessage, createdInjectionMessage); }
private void btnAdd_Click(object sender, EventArgs e) { IInjectionMessageStorage injectionMessageStorage = new InjectionMessageStorage(); InjectionMessage injectionMessage = new InjectionMessage(); if (cmbInjectorName.Text.Trim() == "" || cmbVaccineName.Text.Trim() == "" || textInjectionMessageSite.Text.Trim() == "" || dtpInjectionMessageTime.Text.Trim() == "" || textInjectionMessageDoctor.Text.Trim() == "") { MessageBox.Show("请输入全部信息,不要有遗漏。"); } else { injectionMessage.InjectorID = Convert.ToInt32(cmbInjectorName.SelectedValue.ToString()); injectionMessage.VaccineID = Convert.ToInt32(cmbVaccineName.SelectedValue.ToString()); injectionMessage.InjectionMessageSite = textInjectionMessageSite.Text.Trim(); injectionMessage.InjectionMessageTime = Convert.ToDateTime(dtpInjectionMessageTime.Text.Trim()); injectionMessage.InjectionMessageDoctor = textInjectionMessageDoctor.Text.Trim(); injectionMessageStorage.CreateInjectionMessage(injectionMessage); MessageBox.Show("增加成功!"); cmbInjectorName.Text = ""; cmbVaccineName.Text = ""; textInjectionMessageSite.Text = ""; dtpInjectionMessageTime.Text = ""; textInjectionMessageDoctor.Text = ""; } }
public void InjectionMessageCreateFailureInjectionMessageDoctorArgumentNullException() { IInjectionMessageStorage injectionMessageStorage = new InjectionMessageStorage(); IInjectorStorage pInjectorStorage = new InjectorStorage(); IVaccineStorage pVaccineStorage = new VaccineStorage(); int pgetInjectorID = getInjectorID(); int pgetVaccineID = getVaccineID(); InjectionMessage myInjectionMessage = CreateInjectionMessageForTest( pgetInjectorID, pInjectorStorage.ReadInjector(pgetInjectorID).InjectorName, pgetVaccineID, pVaccineStorage.ReadVaccine(pgetVaccineID).VaccineName, "某某人民医院", "2016-03-30", null); injectionMessageStorage.CreateInjectionMessage(myInjectionMessage); }
public void InjectionMessageUpdateFailureInjectionMessageIdArgumentException() { IInjectionMessageStorage pInjectionMessageStorage = new InjectionMessageStorage(); IInjectorStorage pInjectorStorage = new InjectorStorage(); IVaccineStorage pVaccineStorage = new VaccineStorage(); int pgetInjectorID = getInjectorID(); int pgetVaccineID = getVaccineID(); InjectionMessage myInjectionMessage = CreateInjectionMessageForTest( pgetInjectorID, pInjectorStorage.ReadInjector(pgetInjectorID).InjectorName, pgetVaccineID, pVaccineStorage.ReadVaccine(pgetVaccineID).VaccineName, "某某人民医院", "2016-03-30", "陈医生"); pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage); myInjectionMessage.InjectionMessageID = int.MaxValue; pInjectionMessageStorage.UpdateInjectionMessage(myInjectionMessage); }
public void InjectionMessageListSuccess() { List <InjectionMessage> injectionMessageList = new List <InjectionMessage>(); IInjectionMessageStorage pInjectionMessageStorage = new InjectionMessageStorage(); IInjectorStorage pInjectorStorage = new InjectorStorage(); IVaccineStorage pVaccineStorage = new VaccineStorage(); int pgetInjectorID = getInjectorID(); int pgetVaccineID = getVaccineID(); InjectionMessage myInjectionMessage = CreateInjectionMessageForTest( pgetInjectorID, pInjectorStorage.ReadInjector(pgetInjectorID).InjectorName, pgetVaccineID, pVaccineStorage.ReadVaccine(pgetVaccineID).VaccineName, "某某人民医院", "2016-03-30", "陈医生"); InjectionMessage createdInjectionMessage = pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage); injectionMessageList.Add(createdInjectionMessage); pgetInjectorID = getInjectorID(); myInjectionMessage = CreateInjectionMessageForTest( pgetInjectorID, pInjectorStorage.ReadInjector(pgetInjectorID).InjectorName, createdInjectionMessage.VaccineID, pVaccineStorage.ReadVaccine(createdInjectionMessage.VaccineID).VaccineName, "某某人民医院", "2016-03-30", "陈医生"); createdInjectionMessage = pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage); injectionMessageList.Add(createdInjectionMessage); pgetVaccineID = getVaccineID(); myInjectionMessage = CreateInjectionMessageForTest( createdInjectionMessage.InjectorID, pInjectorStorage.ReadInjector(createdInjectionMessage.InjectorID).InjectorName, pgetVaccineID, pVaccineStorage.ReadVaccine(pgetVaccineID).VaccineName, "某某人民医院", "2016-03-30", "陈医生"); createdInjectionMessage = pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage); injectionMessageList.Add(createdInjectionMessage); myInjectionMessage = CreateInjectionMessageForTest( createdInjectionMessage.InjectorID, pInjectorStorage.ReadInjector(createdInjectionMessage.InjectorID).InjectorName, createdInjectionMessage.VaccineID, pVaccineStorage.ReadVaccine(createdInjectionMessage.VaccineID).VaccineName, "海口市中医院", "2016-03-30", "陈医生"); createdInjectionMessage = pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage); injectionMessageList.Add(createdInjectionMessage); myInjectionMessage = CreateInjectionMessageForTest( createdInjectionMessage.InjectorID, pInjectorStorage.ReadInjector(createdInjectionMessage.InjectorID).InjectorName, createdInjectionMessage.VaccineID, pVaccineStorage.ReadVaccine(createdInjectionMessage.VaccineID).VaccineName, "海口市中医院", "2016-04-25", "陈医生"); createdInjectionMessage = pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage); injectionMessageList.Add(createdInjectionMessage); myInjectionMessage = CreateInjectionMessageForTest( createdInjectionMessage.InjectorID, pInjectorStorage.ReadInjector(createdInjectionMessage.InjectorID).InjectorName, createdInjectionMessage.VaccineID, pVaccineStorage.ReadVaccine(createdInjectionMessage.VaccineID).VaccineName, "海口市中医院", "2016-04-25", "欧阳医生"); createdInjectionMessage = pInjectionMessageStorage.CreateInjectionMessage(myInjectionMessage); injectionMessageList.Add(createdInjectionMessage); QueryInjectionMessage queryInjectionMessage = new QueryInjectionMessage(); queryInjectionMessage.InjectionMessageID = null; queryInjectionMessage.InjectorID = null; queryInjectionMessage.VaccineID = null; queryInjectionMessage.InjectionMessageSite = null; queryInjectionMessage.InjectionMessageTime = null; queryInjectionMessage.InjectionMessageDoctor = null; IList <InjectionMessage> readedInjectionMessageList = pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage); AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList); injectionMessageList.RemoveAt(0); queryInjectionMessage = new QueryInjectionMessage(); queryInjectionMessage.InjectionMessageID = null; queryInjectionMessage.InjectorID = createdInjectionMessage.InjectorID; queryInjectionMessage.VaccineID = null; queryInjectionMessage.InjectionMessageSite = null; queryInjectionMessage.InjectionMessageTime = null; queryInjectionMessage.InjectionMessageDoctor = null; readedInjectionMessageList = pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage); AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList); injectionMessageList.RemoveAt(0); queryInjectionMessage = new QueryInjectionMessage(); queryInjectionMessage.InjectionMessageID = null; queryInjectionMessage.InjectorID = null; queryInjectionMessage.VaccineID = createdInjectionMessage.VaccineID; queryInjectionMessage.InjectionMessageSite = null; queryInjectionMessage.InjectionMessageTime = null; queryInjectionMessage.InjectionMessageDoctor = null; readedInjectionMessageList = pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage); AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList); injectionMessageList.RemoveAt(0); queryInjectionMessage = new QueryInjectionMessage(); queryInjectionMessage.InjectionMessageID = null; queryInjectionMessage.InjectorID = null; queryInjectionMessage.VaccineID = null; queryInjectionMessage.InjectionMessageSite = "海口市中医院"; queryInjectionMessage.InjectionMessageTime = null; queryInjectionMessage.InjectionMessageDoctor = null; readedInjectionMessageList = pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage); AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList); injectionMessageList.RemoveAt(0); queryInjectionMessage = new QueryInjectionMessage(); queryInjectionMessage.InjectionMessageID = null; queryInjectionMessage.InjectorID = null; queryInjectionMessage.VaccineID = null; queryInjectionMessage.InjectionMessageSite = null; queryInjectionMessage.InjectionMessageTime = Convert.ToDateTime("2016-04-25"); queryInjectionMessage.InjectionMessageDoctor = null; readedInjectionMessageList = pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage); AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList); injectionMessageList.RemoveAt(0); queryInjectionMessage = new QueryInjectionMessage(); queryInjectionMessage.InjectionMessageID = null; queryInjectionMessage.InjectorID = null; queryInjectionMessage.VaccineID = null; queryInjectionMessage.InjectionMessageSite = null; queryInjectionMessage.InjectionMessageTime = null; queryInjectionMessage.InjectionMessageDoctor = "欧阳医生"; readedInjectionMessageList = pInjectionMessageStorage.ListInjectionMessage(queryInjectionMessage); AssertInjectionMessageListsEqual(injectionMessageList, readedInjectionMessageList); }
//这个属性其实非常有用处,它表明这个函数会抛出一个预期的异常。 public void InjectionMessageCreateFailureInjectionMessageArgumentNullException() { IInjectionMessageStorage injectionMessageStorage = new InjectionMessageStorage(); injectionMessageStorage.CreateInjectionMessage(null); }