public void PutSpecialtyUpdateSpecialty() { //Test Specialty IHttpActionResult result; CreatedAtRouteNegotiatedContentResult<SpecialtyModel> contentResult; OkNegotiatedContentResult<SpecialtyModel> specialtyResult; OkNegotiatedContentResult<SpecialtyModel> readContentResult; using (var SpecialtyController = new SpecialtiesController()) { //Create Specialty var newSpecialty = new SpecialtyModel { SpecialtyName = "Testologist", }; //Insert SpecialtyModelObject into Database so //that I can take it out and test for update. result = SpecialtyController.PostSpecialty(newSpecialty); //Cast result as Content Result so that I can gather information from ContentResult contentResult = (CreatedAtRouteNegotiatedContentResult<SpecialtyModel>)result; } using (var SecondSpecialtyController = new SpecialtiesController()) { //Result contains the Specialty I had JUST createad result = SecondSpecialtyController.GetSpecialty(contentResult.Content.SpecialtyID); Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<SpecialtyModel>)); //Get SpecialtyModel from 'result' specialtyResult = (OkNegotiatedContentResult<SpecialtyModel>)result; } using (var ThirdSpecialtyController = new SpecialtiesController()) { var modifiedSpecialty = specialtyResult.Content; modifiedSpecialty.SpecialtyName = "Updated Testologist"; //Act //The result of the Put Request result = ThirdSpecialtyController.PutSpecialty(specialtyResult.Content.SpecialtyID, modifiedSpecialty); //Assert Assert.IsInstanceOfType(result, typeof(StatusCodeResult)); } using (var FourthSpecialtyController = new SpecialtiesController()) { //Act IHttpActionResult resultAlteredSpecialty = FourthSpecialtyController.GetSpecialty(specialtyResult.Content.SpecialtyID); OkNegotiatedContentResult<SpecialtyModel> alteredResult = (OkNegotiatedContentResult<SpecialtyModel>)resultAlteredSpecialty; SpecialtyModel updatedSpecialty = (SpecialtyModel)alteredResult.Content; //Assert Assert.IsInstanceOfType(resultAlteredSpecialty, typeof(OkNegotiatedContentResult<SpecialtyModel>)); readContentResult = (OkNegotiatedContentResult<SpecialtyModel>)resultAlteredSpecialty; Assert.IsTrue(readContentResult.Content.SpecialtyName == "Updated Testologist"); } using (var FifthSpecialtyController = new SpecialtiesController()) { //Delete the Test Specialty result = FifthSpecialtyController.DeleteSpecialty(readContentResult.Content.SpecialtyID); } }