public void InjectorUpdateSuccessFive() { IInjectorStorage injectorStorage = new InjectorStorage(); Injector myInjector = CreateInjectorForTest( "李某某", "男", "17733441111", "3", "2013-10-09"); Injector createdInjector = injectorStorage.CreateInjector(myInjector); Assert.AreNotEqual( 0, createdInjector.InjectorID, string.Format("Could not create Injector:{0}", createdInjector.InjectorID)); myInjector.InjectorTime = Convert.ToDateTime("2013-11-13"); injectorStorage.UpdateInjector(myInjector); Injector updatedInjector = injectorStorage.ReadInjector( createdInjector.InjectorID); AssertInjectorItemEqual(myInjector, updatedInjector); }
private void btnAdd_Click(object sender, EventArgs e) { IInjectorStorage injectorStorage = new InjectorStorage(); Injector injector = new Injector(); if (textInjectorName.Text.Trim() == "" || textInjectorSex.Text.Trim() == "" || textInjectorPhone.Text.Trim() == "" || textInjectorNumber.Text.Trim() == "" || dtpInjectorTime.Text.Trim() == "") { MessageBox.Show("请输入全部信息,不要有遗漏。"); } else { injector.InjectorName = textInjectorName.Text.Trim(); injector.InjectorSex = textInjectorSex.Text.Trim(); injector.InjectorPhone = textInjectorPhone.Text.Trim(); injector.InjectorNumber = Convert.ToInt32(textInjectorNumber.Text.Trim()); injector.InjectorTime = Convert.ToDateTime(dtpInjectorTime.Text.Trim()); injectorStorage.CreateInjector(injector); MessageBox.Show("增加成功!"); textInjectorName.Text = ""; textInjectorSex.Text = ""; textInjectorPhone.Text = ""; textInjectorNumber.Text = ""; dtpInjectorTime.Text = ""; } }
public void InjectorCreateFailureInjectorNameArgumentNullException() { IInjectorStorage injectorStorage = new InjectorStorage(); Injector myInjector = CreateInjectorForTest( null, "男", "17733441111", "3", "2013-10-09"); injectorStorage.CreateInjector(myInjector); }
public void InjectorUpdateFailureInjectorIdArgumentException() { IInjectorStorage injectorStorage = new InjectorStorage(); Injector myInjector = CreateInjectorForTest( "李某某", "男", "17733441111", "3", "2013-10-09"); injectorStorage.CreateInjector(myInjector); myInjector.InjectorID = int.MaxValue; injectorStorage.UpdateInjector(myInjector); }
public static int getInjectorID() { IInjectorStorage pInjectorStorage = new InjectorStorage(); Injector myInjector = CreateInjectorForTest( "沈某某", "男", "17733441111", "3", "2013-10-09"); Injector createdInjector = pInjectorStorage.CreateInjector(myInjector); return(createdInjector.InjectorID); }
public void InjectorCreateSuccess() { IInjectorStorage injectorStorage = new InjectorStorage(); Injector myInjector = CreateInjectorForTest( "李某某", "男", "17733441111", "3", "2013-10-09"); Injector createdInjector = injectorStorage.CreateInjector(myInjector); Assert.AreNotEqual( 0, createdInjector.InjectorID, string.Format("Could not create Injector:{0}", createdInjector.InjectorID)); AssertInjectorItemEqual(myInjector, createdInjector); }
public void InjectorReadSuccess() { IInjectorStorage injectorStorage = new InjectorStorage(); Injector myInjector = CreateInjectorForTest( "王某某", "女", "17733441111", "2", "2013-07-09"); Injector createdInjector = injectorStorage.CreateInjector(myInjector); Assert.AreNotEqual( 0, createdInjector.InjectorID, string.Format("Could not create Injector:{0}", createdInjector.InjectorID)); Injector readedInjector = injectorStorage.ReadInjector( createdInjector.InjectorID); AssertInjectorItemEqual(createdInjector, readedInjector); }
//这个属性其实非常有用处,它表明这个函数会抛出一个预期的异常。 public void InjectorCreateFailureInjectorArgumentNullException() { IInjectorStorage injectorStorage = new InjectorStorage(); injectorStorage.CreateInjector(null); }
public void InjectorListSuccess() { List <Injector> injectorList = new List <Injector>(); IInjectorStorage injectorStorage = new InjectorStorage(); Injector myInjector = CreateInjectorForTest( "李某某11", "男11", "17733441111", "3", "2013-10-09"); Injector createdInjector = injectorStorage.CreateInjector(myInjector); injectorList.Add(createdInjector); myInjector = CreateInjectorForTest( "李某某12", "男11", "17733441111", "3", "2013-10-09"); createdInjector = injectorStorage.CreateInjector(myInjector); injectorList.Add(createdInjector); myInjector = CreateInjectorForTest( "李某某12", "男12", "17733441111", "3", "2013-10-09"); createdInjector = injectorStorage.CreateInjector(myInjector); injectorList.Add(createdInjector); myInjector = CreateInjectorForTest( "李某某12", "男12", "17733441112", "3", "2013-10-09"); createdInjector = injectorStorage.CreateInjector(myInjector); injectorList.Add(createdInjector); myInjector = CreateInjectorForTest( "李某某12", "男12", "17733441112", "2", "2013-10-09"); createdInjector = injectorStorage.CreateInjector(myInjector); injectorList.Add(createdInjector); myInjector = CreateInjectorForTest( "李某某12", "男12", "17733441112", "2", "2013-11-09"); createdInjector = injectorStorage.CreateInjector(myInjector); injectorList.Add(createdInjector); QueryInjector queryInjector = new QueryInjector(); queryInjector.InjectorID = null; queryInjector.InjectorName = null; queryInjector.InjectorSex = null; queryInjector.InjectorPhone = null; queryInjector.InjectorNumber = null; queryInjector.InjectorTime = null; IList <Injector> readedInjectorList = injectorStorage.ListInjector(queryInjector); AssertInjectorListsEqual(injectorList, readedInjectorList); injectorList.RemoveAt(0); queryInjector = new QueryInjector(); queryInjector.InjectorID = null; queryInjector.InjectorName = "李某某12"; queryInjector.InjectorSex = null; queryInjector.InjectorPhone = null; queryInjector.InjectorNumber = null; queryInjector.InjectorTime = null; readedInjectorList = injectorStorage.ListInjector(queryInjector); AssertInjectorListsEqual(injectorList, readedInjectorList); injectorList.RemoveAt(0); queryInjector = new QueryInjector(); queryInjector.InjectorID = null; queryInjector.InjectorName = null; queryInjector.InjectorSex = "男12"; queryInjector.InjectorPhone = null; queryInjector.InjectorNumber = null; queryInjector.InjectorTime = null; readedInjectorList = injectorStorage.ListInjector(queryInjector); AssertInjectorListsEqual(injectorList, readedInjectorList); injectorList.RemoveAt(0); queryInjector = new QueryInjector(); queryInjector.InjectorID = null; queryInjector.InjectorName = null; queryInjector.InjectorSex = null; queryInjector.InjectorPhone = "17733441112"; queryInjector.InjectorNumber = null; queryInjector.InjectorTime = null; readedInjectorList = injectorStorage.ListInjector(queryInjector); AssertInjectorListsEqual(injectorList, readedInjectorList); injectorList.RemoveAt(0); queryInjector = new QueryInjector(); queryInjector.InjectorID = null; queryInjector.InjectorName = null; queryInjector.InjectorSex = null; queryInjector.InjectorPhone = null; queryInjector.InjectorNumber = Convert.ToInt32("2"); queryInjector.InjectorTime = null; readedInjectorList = injectorStorage.ListInjector(queryInjector); AssertInjectorListsEqual(injectorList, readedInjectorList); injectorList.RemoveAt(0); queryInjector = new QueryInjector(); queryInjector.InjectorID = null; queryInjector.InjectorName = null; queryInjector.InjectorSex = null; queryInjector.InjectorPhone = null; queryInjector.InjectorNumber = null; queryInjector.InjectorTime = Convert.ToDateTime("2013-11-09"); readedInjectorList = injectorStorage.ListInjector(queryInjector); AssertInjectorListsEqual(injectorList, readedInjectorList); }