public void DeleteEntryDeletesEntry()
        {
            //Arrange:
            // Instantiate EntriessController so its methods can be called
            // Create a new entry to be deleted, and get its entry ID
            var entryController = new EntriesController();

            var entry = new EntryModel
            {
                Name = "Zia Prostnow",
                EntryText = "Whippersnappers!"
            };
            IHttpActionResult result = entryController.PostEntry(entry);
            CreatedAtRouteNegotiatedContentResult<EntryModel> contentResult =
                (CreatedAtRouteNegotiatedContentResult<EntryModel>)result;

            int entryIdToDelete = contentResult.Content.EntryId;

            //Act: Call DeleteEntry
            result = entryController.DeleteEntry(entryIdToDelete);

            //Assert:
            // Verify that HTTP result is OK
            // Verify that reading deleted entry returns result not found
            Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<Entry>));

            result = entryController.GetEntry(entryIdToDelete);
            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
        public void GetEntryReturnsEntry()
        {
            int entryIdForTest = 1;

            //Arrange: Instantiate EntriesController so its methods can be called
            var entryController = new EntriesController();

            //Act: Call the GetEntry method
            IHttpActionResult result = entryController.GetEntry(entryIdForTest);

            //Assert:
            // Verify that HTTP status code is OK
            // Verify that returned entry ID is correct
            Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<EntryModel>));

            OkNegotiatedContentResult<EntryModel> contentResult =
                (OkNegotiatedContentResult<EntryModel>)result;
            Assert.IsTrue(contentResult.Content.EntryId == entryIdForTest);
        }
        public void PutEntryUpdatesEntry()
        {
            int entryIdForTest = 1;
            string nameForTest = "Iphigenia Brown";
            string entryTextForTest = "Hallelujah!";

            //Arrange: Instantiate EntriesController so its methods can be called
            var entryController = new EntriesController();

            //Act:
            // Get an existing entry, change it, and
            //  pass it to PutEntry

            IHttpActionResult result = entryController.GetEntry(entryIdForTest);
            OkNegotiatedContentResult<EntryModel> contentResult =
                (OkNegotiatedContentResult<EntryModel>)result;
            EntryModel updatedEntry = (EntryModel)contentResult.Content;

            string nameBeforeUpdate = updatedEntry.Name;
            string entryTextBeforeUpdate = updatedEntry.EntryText;

            updatedEntry.Name = nameForTest;
            updatedEntry.EntryText = entryTextForTest;

            result = entryController.PutEntry
                                     (updatedEntry.EntryId, updatedEntry);

            //Assert:
            // Verify that HTTP status code is OK
            // Get the entry and verify that it was updated

            var statusCode = (StatusCodeResult)result;

            Assert.IsTrue(statusCode.StatusCode == System.Net.HttpStatusCode.NoContent);

            result = entryController.GetEntry(entryIdForTest);

            Assert.IsInstanceOfType(result,
                typeof(OkNegotiatedContentResult<EntryModel>));

            OkNegotiatedContentResult<EntryModel> readContentResult =
                (OkNegotiatedContentResult<EntryModel>)result;
            updatedEntry = (EntryModel)readContentResult.Content;

            Assert.IsTrue(updatedEntry.Name == nameForTest);
            Assert.IsTrue(updatedEntry.EntryText == entryTextForTest);

            updatedEntry.Name = nameBeforeUpdate;
            updatedEntry.EntryText = entryTextBeforeUpdate;

            /*
            updatedEntry.Name = "Sally Smith";
            updatedEntry.EntryText = "Great place!";
            */

            result = entryController.PutEntry
                                 (updatedEntry.EntryId, updatedEntry);
        }