public void GetContactModelsBySiteId() { List <ContactModel> l_list = new List <ContactModel>(); //新建一个表,验证表 IContactDAO ICD = new ContactDAOImpl();//调用接口 ContactModel l_CL = new ContactModel() { Id = 1, Contact_name = "song", Contact_email = "sing", Create_time = DateTime.Now, Update_time = DateTime.Now, Others = null, Telephone = null, }; ICD.InsertOneContact(l_CL); //为了防止数据库起初没数据,为表插入一条Contact信息,使测试通过 IContactSiteDao contactSiteDao = ContactSiteDAOImpl.Instance; contactSiteDao.InsertListConnects(new List <SiteContactModel>() { new SiteContactModel() { SiteId = 1, ContactId = l_CL.Id //注意Contact里面的Id是自动生成,不一定是输入的值,所以ContactSite的Id需要获取一下当前Contact的Id } }); //插入一条ContactSite信息 l_list = ICD.GetContactModelsBySiteId(1); Assert.AreNotEqual(l_list.Count, 0); //已经有数据看结果是否有值,验证方法 }
public void TestFindByIdContact() { using (ContactDAOImpl daoImp = new ContactDAOImpl()) { Contact c = daoImp.FindByID("*****@*****.**"); Assert.AreEqual(c.ContactID, 2); } }
public void TestFindAllContact() { List <Contact> c = new List <Contact>(); using (ContactDAOImpl daoImp = new ContactDAOImpl()) { c = daoImp.FindAll(); Assert.IsNotNull(c); } }
public void TestRemoveContact() { Contact c = new Contact() { ContactID = 3, CellNumber = "0768923745", TellphoneNumber = "0219399900", Email = "*****@*****.**" }; using (ContactDAOImpl daoImp = new ContactDAOImpl()) { bool isPer = daoImp.Remove(c); Assert.IsTrue(isPer); } }
public void TestPersistContact() { Contact c = new Contact() { ContactID = 5, CellNumber = "0768992895", TellphoneNumber = "0219399999", Email = "*****@*****.**" }; using (ContactDAOImpl daoImpl = new ContactDAOImpl()){ bool isPer = daoImpl.Persist(c); Assert.IsTrue(isPer); } }
public void TestInsertContact() { Employee e = new Employee() { EmployeeID = 1, Firstname = "Noma", Lastname = "Mhlophe", PersonnelNum = 3335, JobTitle = "IS Operations Manager", Position = "Finance Services Manager", ExitDate = null, HireDate = null, }; using (EmployeeDAOImpl daoImpl = new EmployeeDAOImpl()) { bool isPer = daoImpl.Persist(e); Assert.IsTrue(isPer); } Contact c = new Contact() { ContactID = 1, EmployeeID = e.EmployeeID, CellNumber = "0768923715", TellphoneNumber = "0219399999", Email = "*****@*****.**" }; using (ContactDAOImpl daoImpl = new ContactDAOImpl()) { bool isPer = daoImpl.Persist(c); Assert.IsTrue(isPer); } }