public void TestDeleteIndex() { const int contactId = 1; ContactsController controller = new ContactsController(_repository); JsonResult result = controller.Delete(contactId) as JsonResult; result = controller.Index() as JsonResult; List<Contact> contacts = result.Data as List<Contact>; Assert.AreEqual(2, contacts.Count()); }
public void TestDeleteGet() { const int contactId = 1; ContactsController controller = new ContactsController(_repository); JsonResult result = controller.Delete(contactId) as JsonResult; try { result = controller.Get(contactId) as JsonResult; Assert.Fail("Contact was not deleted."); } catch (System.Collections.Generic.KeyNotFoundException ex) { return; } }