public void TestGet()
 {
     const int idToGet = 2;
     ContactsController controller = new ContactsController(_repository);
     JsonResult result = controller.Get(idToGet) as JsonResult;
     Contact contact = result.Data as Contact;
     Assert.AreEqual(idToGet, contact.Id);
 }
 public void Get_Must_Return_Href()
 {
     const int idToGet = 2;
     ContactsController controller = new ContactsController(_repository);
     JsonResult result = controller.Get(idToGet) as JsonResult;
     Contact contact = result.Data as Contact;
     Assert.AreEqual("/contacts/2", contact.Href);
 }
 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;
     }
 }
 public void TestPost()
 {
     const int contactId = 4;
     const string contactName = "Contact four";
     Contact newContact = new Contact { Id = contactId, Name = contactName, Email = "*****@*****.**", Phone = "555-4444" };
     ContactsController controller = new ContactsController(_repository);
     JsonResult result = controller.Post(newContact) as JsonResult;
     result = controller.Get(contactId) as JsonResult;
     Contact contact = result.Data as Contact;
     Assert.AreEqual(contactName, contact.Name);
 }
 public void TestPut()
 {
     const int contactId = 3;
     const string contactName = "Updated contact";
     Contact updatedContact = new Contact { Id = contactId, Name = contactName, Email = "*****@*****.**", Phone = "555-7777" };
     ContactsController controller = new ContactsController(_repository);
     JsonResult result = controller.Put(contactId, updatedContact) as JsonResult;
     result = controller.Get(contactId) as JsonResult;
     Contact contact = result.Data as Contact;
     Assert.AreEqual(contactName, contact.Name);
 }