public void AddTest() { ContactService service = new ContactService(); service.Clear(); var contact = GetContact(); var id = service.Add(contact); Assert.IsTrue(id > 0); }
public void DeleteTest() { ContactService service = new ContactService(); var all = service.GetAll(); if (all.Count == 0) { AddTest(); all = service.GetAll(); } var contact = all[0]; service.Delete(contact); var updatedAll = service.GetAll(); var deleted = updatedAll.Find(c => c.Id == contact.Id); Assert.IsTrue(deleted == null); }
public void UpdateTest() { ContactService service = new ContactService(); var all = service.GetAll(); if (service.GetAll().Count <= 0) { AddTest(); all = service.GetAll(); } var contact = all[0]; contact.Email = "*****@*****.**"; service.Update(contact); var updatedAll = service.GetAll(); var actual = updatedAll.Find(c => c.Id == contact.Id); Assert.AreEqual(contact.Email, actual.Email); }
public ContactsController() { _service = new ContactService(); }
public void UpdateTest() { ContactService service = new ContactService(); var all = service.GetAll(); if (service.GetAll().Count <= 0) { AddTest(); all = service.GetAll(); } var contact = all[0]; contact.emails = new List<string>() { "*****@*****.**" }; service.Update(contact); var updatedAll = service.GetAll(); var actual = updatedAll.Find(c => c.id == contact.id); Assert.AreEqual(contact.emails[0], actual.emails[0]); }