public void DeleteExamRoom()
        {
            CreatedAtRouteNegotiatedContentResult<ExamRoomModel> contentResult;

            using (var ExamRoomController = new ExamRoomsController())
            {
                //Create Exam Room
                var newExamRoom = new ExamRoomModel
                {
                    ExamRoomName = "Test Room"
                };
                //Insert ExamRoomModelObject into Database so
                //that I can delete it
                var result = ExamRoomController.PostExamRoom(newExamRoom);

                //Cast result as Content Result so that I can gather information from ContentResult
                contentResult = (CreatedAtRouteNegotiatedContentResult<ExamRoomModel>)result;
            }
            using (var SecondExamRoomController = new ExamRoomsController())
            {
                //Delete the Test Exam Room
                var result = SecondExamRoomController.DeleteExamRoom(contentResult.Content.ExamRoomID);

                //Assert
                Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<ExamRoomModel>));
            }
            using (var ThirdExamRoomController = new ExamRoomsController())
            {
                var result = ThirdExamRoomController.GetExamRoom(contentResult.Content.ExamRoomID);

                //Assert
                Assert.IsInstanceOfType(result, typeof(NotFoundResult));
            }
        }
        public void GetRoomReturnRoom()
        {
            int examRoomIDForTest;

            //Arrange: create a test exam room, and save its ID
            using (var examRoomController = new ExamRoomsController())
            {
                var examRoom = new ExamRoomModel
                {
                    ExamRoomName = "ImexamRoom"
                };
                IHttpActionResult result = examRoomController.PostExamRoom(examRoom);
                CreatedAtRouteNegotiatedContentResult<ExamRoomModel> examRoomContentResult =
                    (CreatedAtRouteNegotiatedContentResult<ExamRoomModel>)result;
                examRoomIDForTest = examRoomContentResult.Content.ExamRoomID;
            }

            using (var examRoomController = new ExamRoomsController())
            {
                //Act
                IHttpActionResult result = examRoomController.GetExamRoom(examRoomIDForTest);

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

                OkNegotiatedContentResult<ExamRoomModel> contentResult = (OkNegotiatedContentResult<ExamRoomModel>)result;

                Assert.IsTrue(contentResult.Content.ExamRoomID == examRoomIDForTest);

            }

            // Delete the test exam room
            using (var examRoomController = new ExamRoomsController())
            {
                IHttpActionResult result = examRoomController.DeleteExamRoom(examRoomIDForTest);
            }
        }
        public void PutRoomUpdateRoom()
        {
            //Test Exam Rooms
            IHttpActionResult result;
            CreatedAtRouteNegotiatedContentResult<ExamRoomModel> contentResult;
            OkNegotiatedContentResult<ExamRoomModel> examRoomResult;
            OkNegotiatedContentResult<ExamRoomModel> readContentResult;

            using (var ExamRoomController = new ExamRoomsController())
            {
                //Create test exam room
                var newExamRoom = new ExamRoomModel
                {
                    ExamRoomName = "Test Room",

                };
                //Insert ExamRoomModelObject into Database so
                //that I can take it out and test for update.
                result = ExamRoomController.PostExamRoom(newExamRoom);

                //Cast result as Content Result so that I can gather information from ContentResult
                contentResult = (CreatedAtRouteNegotiatedContentResult<ExamRoomModel>)result;
            }
            using (var SecondExamRoomController = new ExamRoomsController())
            {
                //Result contains the ExamRoom I had JUST createad
                result = SecondExamRoomController.GetExamRoom(contentResult.Content.ExamRoomID);

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

                //Get ExamRoomModel from 'result'
                examRoomResult = (OkNegotiatedContentResult<ExamRoomModel>)result;

            }

            using (var ThirdExamRoomController = new ExamRoomsController())
            {
                var modifiedExamRoom = examRoomResult.Content;

                modifiedExamRoom.ExamRoomName = "Updated Test Room";

                //Act
                //The result of the Put Request
                result = ThirdExamRoomController.PutExamRoom(examRoomResult.Content.ExamRoomID, modifiedExamRoom);

                //Assert
                Assert.IsInstanceOfType(result, typeof(StatusCodeResult));
            }
            using (var FourthExamRoomController = new ExamRoomsController())
            {
                //Act
                IHttpActionResult resultAlteredExamRoom = FourthExamRoomController.GetExamRoom(examRoomResult.Content.ExamRoomID);

                OkNegotiatedContentResult<ExamRoomModel> alteredResult = (OkNegotiatedContentResult<ExamRoomModel>)resultAlteredExamRoom;
                ExamRoomModel updatedExamRoom = (ExamRoomModel)alteredResult.Content;

                //Assert
                Assert.IsInstanceOfType(resultAlteredExamRoom, typeof(OkNegotiatedContentResult<ExamRoomModel>));

                readContentResult =
                    (OkNegotiatedContentResult<ExamRoomModel>)resultAlteredExamRoom;

                Assert.IsTrue(readContentResult.Content.ExamRoomName == "Updated Test Room");
            }
            using (var FifthExamRoomController = new ExamRoomsController())
            {
                //Delete the Test Exam Room
                result = FifthExamRoomController.DeleteExamRoom(readContentResult.Content.ExamRoomID);
            }
        }
        public void GetRoomsReturnRooms()
        {
            using (var ExamRoomController = new ExamRoomsController())
            {

                //Act: Call the Get ExamRoom Method
                IEnumerable<ExamRoomModel> examRooms = ExamRoomController.GetExamRooms();

                if(!examRooms.Any()) Assert.Inconclusive();

                //Assert
                Assert.IsTrue(examRooms.Count() > 0);
            }
        }
        public void PostRoomCreateRoom()
        {
            //Arrange
            using (var ExamRoomController = new ExamRoomsController())
            {
                //Create Exam Room
                var newExamRoom = new ExamRoomModel
                {
                    ExamRoomName = "Test Room",
                };

                //Act
                IHttpActionResult result = ExamRoomController.PostExamRoom(newExamRoom);

                //Assert
                Assert.IsInstanceOfType(result, typeof(CreatedAtRouteNegotiatedContentResult<ExamRoomModel>));

                CreatedAtRouteNegotiatedContentResult<ExamRoomModel> contentResult = (CreatedAtRouteNegotiatedContentResult<ExamRoomModel>)result;

                Assert.IsTrue(contentResult.Content.ExamRoomID != 0);

                //Delete the Test Exam Room
                result = ExamRoomController.DeleteExamRoom(contentResult.Content.ExamRoomID);

            }
        }
        public void PutAppointmentReturnAppointment()
        {
            //Test Properties
            IHttpActionResult result;
            CreatedAtRouteNegotiatedContentResult<AppointmentModel> contentResult;
            OkNegotiatedContentResult<AppointmentModel> appointmentResult;
            OkNegotiatedContentResult<AppointmentModel> readContentResult;

            int createdPatientID;
            int createdDoctorID;
            int createdExamRoomID;
            int changedExamRoomID;
            int createdSpecialtyID;

            //Arrange: create test patient, specialty, doctor, exam rooms, and appointment
            // Create a new test patient, and get its patient ID
            using (var patientController = new PatientsController())
            {
                var patient = new PatientModel
                {
                    FirstName = "Impatient",
                    LastName = "Patience",
                    Birthdate = new DateTime(1968, 12, 27),
                    Email = "*****@*****.**",
                    BloodType = "A+",
                    CreatedDate = DateTime.Now,
                    Archived = false
                };
                result = patientController.PostPatient(patient);
                CreatedAtRouteNegotiatedContentResult<PatientModel> patientContentResult =
                    (CreatedAtRouteNegotiatedContentResult<PatientModel>)result;
                createdPatientID = patientContentResult.Content.PatientID;
            }

            // Create a new test specialty, and get its specialty ID
            using (var specialtyController = new SpecialtiesController())
            {
                var specialty = new SpecialtyModel
                {
                    SpecialtyName = "Very Special Doctor"
                };
                result = specialtyController.PostSpecialty(specialty);
                CreatedAtRouteNegotiatedContentResult<SpecialtyModel> specialtyContentResult =
                    (CreatedAtRouteNegotiatedContentResult<SpecialtyModel>)result;
                createdSpecialtyID = specialtyContentResult.Content.SpecialtyID;
            }

            // Create a new test doctor, and get its doctor ID
            using (var doctorController = new DoctorsController())
            {
                var doctor = new DoctorModel
                {
                    FirstName = "Imdoctor",
                    LastName = "Hippocrates",
                    Email = "*****@*****.**",
                    Telephone = "555-1212",
                    CreatedDate = DateTime.Now,
                    SpecialtyID = createdSpecialtyID,
                    Archived = false
                };
                result = doctorController.PostDoctor(doctor);
                CreatedAtRouteNegotiatedContentResult<DoctorModel> doctorContentResult =
                    (CreatedAtRouteNegotiatedContentResult<DoctorModel>)result;
                createdDoctorID = doctorContentResult.Content.DoctorID;
            }

            // Create new test exam rooms, and get the exam room IDs
            using (var examRoomController = new ExamRoomsController())
            {
                var examRoom = new ExamRoomModel
                {
                    ExamRoomName = "ImexamRoom"
                };
                result = examRoomController.PostExamRoom(examRoom);
                CreatedAtRouteNegotiatedContentResult<ExamRoomModel> examRoomContentResult =
                    (CreatedAtRouteNegotiatedContentResult<ExamRoomModel>)result;
                createdExamRoomID = examRoomContentResult.Content.ExamRoomID;
            }

            using (var examRoomController = new ExamRoomsController())
            {
                var examRoom = new ExamRoomModel
                {
                    ExamRoomName = "AnotherexamRoom"
                };
                result = examRoomController.PostExamRoom(examRoom);
                CreatedAtRouteNegotiatedContentResult<ExamRoomModel> examRoomContentResult =
                    (CreatedAtRouteNegotiatedContentResult<ExamRoomModel>)result;
                changedExamRoomID = examRoomContentResult.Content.ExamRoomID;
            }

            using (var apptController = new AppointmentsController())
            {
                //Create Appointment
                var newAppt = new AppointmentModel
                {
                    DoctorID = createdDoctorID,
                    CheckinDateTime = DateTime.Now,
                    CheckoutDateTime = DateTime.Now.AddHours(2),
                    ExamRoomID = createdExamRoomID,
                    PatientID = createdPatientID
                };

                //Insert Appointment Model Object into Database
                //So that I can take it out and test for update
                result = apptController.PostAppointment(newAppt);

                //Cast result as Content Result so that I can gather information from Content Result
                contentResult = (CreatedAtRouteNegotiatedContentResult<AppointmentModel>)result;
            }

            using (var SecondAppointmentController = new AppointmentsController())
            {
                //Result contains the Appoint I have JUST creatd
                result = SecondAppointmentController.GetAppointment(contentResult.Content.AppointmentID);

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

                //Get AppointmentModel from 'result'
                appointmentResult = (OkNegotiatedContentResult<AppointmentModel>)result;
            }

            using (var ThirdAppointmentController = new AppointmentsController())
            {
                var modifiedAppointment = appointmentResult.Content;

                modifiedAppointment.ExamRoomID = changedExamRoomID;

                //Act
                //The result of the PUT request
                result = ThirdAppointmentController.PutAppointment(appointmentResult.Content.AppointmentID, modifiedAppointment);

                //Assert
                Assert.IsInstanceOfType(result, typeof(StatusCodeResult));
            }

            //Modify Appointment
            using (var FourthAppointmentController = new AppointmentsController())
            {
                IHttpActionResult resultAlteredAppointment = FourthAppointmentController.GetAppointment(appointmentResult.Content.AppointmentID);

                OkNegotiatedContentResult<AppointmentModel> alteredResult = (OkNegotiatedContentResult<AppointmentModel>)resultAlteredAppointment;
                AppointmentModel updatedAppointment = (AppointmentModel)alteredResult.Content;

                //Assert
                Assert.IsInstanceOfType(resultAlteredAppointment, typeof(OkNegotiatedContentResult<AppointmentModel>));

                readContentResult = (OkNegotiatedContentResult<AppointmentModel>)resultAlteredAppointment;

                Assert.IsTrue(readContentResult.Content.ExamRoomID == changedExamRoomID);
            }

            using (var fifthAppointmentController = new AppointmentsController())
            {
                //Delete test Appointment
                result = fifthAppointmentController.DeleteAppointment(readContentResult.Content.AppointmentID);
            }

            // Remove the test doctor and patient from the database with actual deletion, not archiving
            using (MedAgendaDbContext db = new MedAgendaDbContext())
            {
                Doctor dbDoctor = db.Doctors.Find(createdDoctorID);
                db.Doctors.Remove(dbDoctor);
                Patient dbPatient = db.Patients.Find(createdPatientID);
                db.Patients.Remove(dbPatient);
                db.SaveChanges();
            }

            // Delete the test exam rooms
            using (var SecondExamRoomController = new ExamRoomsController())
            {
                result = SecondExamRoomController.DeleteExamRoom(createdExamRoomID);
            }
            using (var SecondExamRoomController = new ExamRoomsController())
            {
                result = SecondExamRoomController.DeleteExamRoom(changedExamRoomID);
            }

            // Delete the test specialty
            using (var specialtyController = new SpecialtiesController())
            {
                result = specialtyController.DeleteSpecialty(createdSpecialtyID);
            }
        }
        public void PostAppointmentCreateAppointment()
        {
            int createdPatientID;
            int appointmentIDForTest;
            int createdDoctorID;
            int createdExamRoomID;
            int createdSpecialtyID;
            CreatedAtRouteNegotiatedContentResult<AppointmentModel> contentResult;

            //Create test patient, specialty, doctor, and exam room for appointment
            // Create a new test patient, and get its patient ID
            using (var patientController = new PatientsController())
            {
                var patient = new PatientModel
                {
                    FirstName = "Impatient",
                    LastName = "Patience",
                    Birthdate = new DateTime(1968, 12, 27),
                    Email = "*****@*****.**",
                    BloodType = "A+",
                    CreatedDate = DateTime.Now,
                    Archived = false
                };
                IHttpActionResult result = patientController.PostPatient(patient);
                CreatedAtRouteNegotiatedContentResult<PatientModel> patientContentResult =
                    (CreatedAtRouteNegotiatedContentResult<PatientModel>)result;
                createdPatientID = patientContentResult.Content.PatientID;
            }

            // Create a new test specialty, and get its specialty ID
            using (var specialtyController = new SpecialtiesController())
            {
                var specialty = new SpecialtyModel
                {
                    SpecialtyName = "Very Special Doctor"
                };
                IHttpActionResult result = specialtyController.PostSpecialty(specialty);
                CreatedAtRouteNegotiatedContentResult<SpecialtyModel> specialtyContentResult =
                    (CreatedAtRouteNegotiatedContentResult<SpecialtyModel>)result;
                createdSpecialtyID = specialtyContentResult.Content.SpecialtyID;
            }

            // Create a new test doctor, and get its doctor ID
            using (var doctorController = new DoctorsController())
            {
                var doctor = new DoctorModel
                {
                    FirstName = "Imdoctor",
                    LastName = "Hippocrates",
                    Email = "*****@*****.**",
                    Telephone = "555-1212",
                    CreatedDate = DateTime.Now,
                    SpecialtyID = createdSpecialtyID,
                    Archived = false
                };
                IHttpActionResult result = doctorController.PostDoctor(doctor);
                CreatedAtRouteNegotiatedContentResult<DoctorModel> doctorContentResult =
                    (CreatedAtRouteNegotiatedContentResult<DoctorModel>)result;
                createdDoctorID = doctorContentResult.Content.DoctorID;
            }

            // Create a new test exam room, and get its exam room ID
            using (var examRoomController = new ExamRoomsController())
            {
                var examRoom = new ExamRoomModel
                {
                    ExamRoomName = "ImexamRoom"
                };
                IHttpActionResult result = examRoomController.PostExamRoom(examRoom);
                CreatedAtRouteNegotiatedContentResult<ExamRoomModel> examRoomContentResult =
                    (CreatedAtRouteNegotiatedContentResult<ExamRoomModel>)result;
                createdExamRoomID = examRoomContentResult.Content.ExamRoomID;
            }

            //Arrange:
            using (var apptController = new AppointmentsController())
            {
                var newAppt = new AppointmentModel
                {
                    DoctorID = createdDoctorID,
                    CheckinDateTime = DateTime.Now,
                    CheckoutDateTime = DateTime.Now.AddHours(2),
                    ExamRoomID = createdExamRoomID,
                    PatientID = createdPatientID
                };

                //Act
                IHttpActionResult result = apptController.PostAppointment(newAppt);

                //Assert
                Assert.IsInstanceOfType(result, typeof(CreatedAtRouteNegotiatedContentResult<AppointmentModel>));

                contentResult = (CreatedAtRouteNegotiatedContentResult<AppointmentModel>)result;

                Assert.IsTrue(contentResult.Content.AppointmentID != 0);
                appointmentIDForTest = contentResult.Content.AppointmentID;
            }

            //Delete the Appointment
            using (var SecondapptController = new AppointmentsController())
            {
              IHttpActionResult result = SecondapptController.DeleteAppointment(appointmentIDForTest);
            }

            // Remove the test doctor and patient from the database with actual deletion, not archiving
            using (MedAgendaDbContext db = new MedAgendaDbContext())
            {
                Doctor dbDoctor = db.Doctors.Find(createdDoctorID);
                db.Doctors.Remove(dbDoctor);
                Patient dbPatient = db.Patients.Find(createdPatientID);
                db.Patients.Remove(dbPatient);
                db.SaveChanges();
            }

            // Delete the test exam room
            using (var SecondExamRoomController = new ExamRoomsController())
            {
                IHttpActionResult result = SecondExamRoomController.DeleteExamRoom(createdExamRoomID);
            }

            // Delete the test specialty
            using (var specialtyController = new SpecialtiesController())
            {
                IHttpActionResult result = specialtyController.DeleteSpecialty(createdSpecialtyID);
            }
        }
        public void PutDoctorCheckUpdateDoctorCheck()
        {
            int createdDoctorID;
            int createdExamRoomID;
            int changedExamRoomID;
            int createdSpecialtyID;
            int doctorCheckIDForTest;

            IHttpActionResult result;
            CreatedAtRouteNegotiatedContentResult<DoctorCheckModel> createdContentResult;
            OkNegotiatedContentResult<DoctorCheckModel> OkContentResult;
            DoctorCheckModel updatedDoctorCheck;

            //Arrange: create test specialty, doctor, and exam rooms
            // Create a new test specialty, and get its specialty ID
            using (var specialtyController = new SpecialtiesController())
            {
                var specialty = new SpecialtyModel
                {
                    SpecialtyName = "Very Special Doctor"
                };
                result = specialtyController.PostSpecialty(specialty);
                CreatedAtRouteNegotiatedContentResult<SpecialtyModel> specialtyContentResult =
                    (CreatedAtRouteNegotiatedContentResult<SpecialtyModel>)result;
                createdSpecialtyID = specialtyContentResult.Content.SpecialtyID;
            }

            // Create a new test doctor, and get its doctor ID
            using (var doctorController = new DoctorsController())
            {
                var doctor = new DoctorModel
                {
                    FirstName = "Imdoctor",
                    LastName = "Hippocrates",
                    Email = "*****@*****.**",
                    Telephone = "555-1212",
                    CreatedDate = DateTime.Now,
                    SpecialtyID = createdSpecialtyID,
                    Archived = false
                };
                result = doctorController.PostDoctor(doctor);
                CreatedAtRouteNegotiatedContentResult<DoctorModel> doctorContentResult =
                    (CreatedAtRouteNegotiatedContentResult<DoctorModel>)result;
                createdDoctorID = doctorContentResult.Content.DoctorID;
            }

            // Create new test exam rooms, and save exam room IDs
            using (var examRoomController = new ExamRoomsController())
            {
                var examRoom = new ExamRoomModel
                {
                    ExamRoomName = "ImexamRoom"
                };
                result = examRoomController.PostExamRoom(examRoom);
                CreatedAtRouteNegotiatedContentResult<ExamRoomModel> examRoomContentResult =
                    (CreatedAtRouteNegotiatedContentResult<ExamRoomModel>)result;
                createdExamRoomID = examRoomContentResult.Content.ExamRoomID;
            }
            using (var examRoomController = new ExamRoomsController())
            {
                var examRoom = new ExamRoomModel
                {
                    ExamRoomName = "AnotherexamRoom"
                };
                result = examRoomController.PostExamRoom(examRoom);
                CreatedAtRouteNegotiatedContentResult<ExamRoomModel> examRoomContentResult =
                    (CreatedAtRouteNegotiatedContentResult<ExamRoomModel>)result;
                changedExamRoomID = examRoomContentResult.Content.ExamRoomID;
            }

            //Arrange: Add new doctorCheck, and save its doctorCheckID
            using (var doctorsCheckController = new DoctorsCheckController())
            {
                var newDoctorCheck = new DoctorCheckModel
                {
                    DoctorID = createdDoctorID,
                    ExamRoomID = createdExamRoomID,
                    CheckinDateTime = DateTime.Now,
                    CheckoutDateTime = DateTime.Now.AddHours(2),
                };
                result = doctorsCheckController.PostDoctorCheck(newDoctorCheck);
                createdContentResult =
                    (CreatedAtRouteNegotiatedContentResult<DoctorCheckModel>)result;
                doctorCheckIDForTest = createdContentResult.Content.DoctorCheckID;
            }

            // Get the doctorCheck from the DB
            using (var doctorsCheckController = new DoctorsCheckController())
            {
                result = doctorsCheckController.GetDoctorCheck(doctorCheckIDForTest);
                OkContentResult =
                    (OkNegotiatedContentResult<DoctorCheckModel>)result;
                updatedDoctorCheck = (DoctorCheckModel)createdContentResult.Content;
            }

            using (var doctorsCheckController = new DoctorsCheckController())
            {
                updatedDoctorCheck.ExamRoomID = changedExamRoomID;

                result = doctorsCheckController.PutDoctorCheck
                                         (updatedDoctorCheck.DoctorCheckID, updatedDoctorCheck);
            }

            // Verify that HTTP status code is OK
            // Get the doctor check and verify that it was updated

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

            using (var doctorsCheckController = new DoctorsCheckController())
            {
                result = doctorsCheckController.GetDoctorCheck(doctorCheckIDForTest);

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

                OkContentResult =
                    (OkNegotiatedContentResult<DoctorCheckModel>)result;
                updatedDoctorCheck = (DoctorCheckModel)OkContentResult.Content;
            }

            Assert.IsTrue(updatedDoctorCheck.ExamRoomID == changedExamRoomID);

            // Delete the test doctorCheck
            using (var doctorsCheckController = new DoctorsCheckController())
            {
                result = doctorsCheckController.DeleteDoctorCheck(doctorCheckIDForTest);
            }

            // Remove the test doctor from the database with actual deletion, not archiving
            using (MedAgendaDbContext db = new MedAgendaDbContext())
            {
                Doctor dbDoctor = db.Doctors.Find(createdDoctorID);
                db.Doctors.Remove(dbDoctor);
                db.SaveChanges();
            }

            // Delete the test exam rooms
            using (var SecondExamRoomController = new ExamRoomsController())
            {
                result = SecondExamRoomController.DeleteExamRoom(createdExamRoomID);
            }
            using (var SecondExamRoomController = new ExamRoomsController())
            {
                result = SecondExamRoomController.DeleteExamRoom(changedExamRoomID);
            }

            // Delete the test specialty
            using (var specialtyController = new SpecialtiesController())
            {
                result = specialtyController.DeleteSpecialty(createdSpecialtyID);
            }
        }
        public void PostDoctorCheckCreatesDoctorCheck()
        {
            int createdDoctorID;
            int createdExamRoomID;
            int createdSpecialtyID;
            int doctorCheckIDForTest;
            IHttpActionResult result;

            //Arrange: create test specialty, doctor, and exam room
            // Create a new test specialty, and get its specialty ID
            using (var specialtyController = new SpecialtiesController())
            {
                var specialty = new SpecialtyModel
                {
                    SpecialtyName = "Very Special Doctor"
                };
                result = specialtyController.PostSpecialty(specialty);
                CreatedAtRouteNegotiatedContentResult<SpecialtyModel> specialtyContentResult =
                    (CreatedAtRouteNegotiatedContentResult<SpecialtyModel>)result;
                createdSpecialtyID = specialtyContentResult.Content.SpecialtyID;
            }

            // Create a new test doctor, and get its doctor ID
            using (var doctorController = new DoctorsController())
            {
                var doctor = new DoctorModel
                {
                    FirstName = "Imdoctor",
                    LastName = "Hippocrates",
                    Email = "*****@*****.**",
                    Telephone = "555-1212",
                    CreatedDate = DateTime.Now,
                    SpecialtyID = createdSpecialtyID,
                    Archived = false
                };
                result = doctorController.PostDoctor(doctor);
                CreatedAtRouteNegotiatedContentResult<DoctorModel> doctorContentResult =
                    (CreatedAtRouteNegotiatedContentResult<DoctorModel>)result;
                createdDoctorID = doctorContentResult.Content.DoctorID;
            }

            // Create a new test exam room, and get its exam room ID
            using (var examRoomController = new ExamRoomsController())
            {
                var examRoom = new ExamRoomModel
                {
                    ExamRoomName = "ImexamRoom"
                };
                result = examRoomController.PostExamRoom(examRoom);
                CreatedAtRouteNegotiatedContentResult<ExamRoomModel> examRoomContentResult =
                    (CreatedAtRouteNegotiatedContentResult<ExamRoomModel>)result;
                createdExamRoomID = examRoomContentResult.Content.ExamRoomID;
            }

            //Arrange: Instantiate DoctorCheckController so its methods can be called
            using (var doctorCheckController = new DoctorsCheckController())
            {
                //Act:
                // Create a DcotorCheckModel object populated with test data,
                //  and call PostDoctorCheck
                var newDoctorCheck = new DoctorCheckModel
                {
                    DoctorID = createdDoctorID,
                    ExamRoomID = createdExamRoomID,
                    CheckinDateTime = DateTime.Now,
                    CheckoutDateTime = DateTime.Now.AddHours(2)
                };
                result = doctorCheckController.PostDoctorCheck(newDoctorCheck);

                //Assert:
                // Verify that the HTTP result is CreatedAtRouteNegotiatedContentResult
                // Verify that the HTTP result body contains a nonzero doctorCheck ID
                Assert.IsInstanceOfType
                    (result, typeof(CreatedAtRouteNegotiatedContentResult<DoctorCheckModel>));
                CreatedAtRouteNegotiatedContentResult<DoctorCheckModel> contentResult =
                    (CreatedAtRouteNegotiatedContentResult<DoctorCheckModel>)result;
                Assert.IsTrue(contentResult.Content.DoctorCheckID != 0);
                doctorCheckIDForTest = contentResult.Content.DoctorCheckID;
            }

            // Delete the test doctorCheck
            using (var doctorCheckController = new DoctorsCheckController())
            {
                result = doctorCheckController.DeleteDoctorCheck(doctorCheckIDForTest);
            }

            // Remove the test doctor from the database with actual deletion, not archiving
            using (MedAgendaDbContext db = new MedAgendaDbContext())
            {
                Doctor dbDoctor = db.Doctors.Find(createdDoctorID);
                db.Doctors.Remove(dbDoctor);
                db.SaveChanges();
            }

            // Delete the test exam room
            using (var SecondExamRoomController = new ExamRoomsController())
            {
                result = SecondExamRoomController.DeleteExamRoom(createdExamRoomID);
            }

            // Delete the test specialty
            using (var specialtyController = new SpecialtiesController())
            {
                result = specialtyController.DeleteSpecialty(createdSpecialtyID);
            }
        }
        public void DeleteDoctorsCheck()
        {
            int createdDoctorID;
            int createdExamRoomID;
            int createdSpecialtyID;
            int doctorsCheckIDForTest;

            IHttpActionResult result;
            CreatedAtRouteNegotiatedContentResult<DoctorCheckModel> createdContentResult;

            //Arrange: create test specialty, doctor, exam room, and doctor check-in
            // Create a new test specialty, and get its specialty ID
            using (var specialtyController = new SpecialtiesController())
            {
                var specialty = new SpecialtyModel
                {
                    SpecialtyName = "Very Special Doctor"
                };
                result = specialtyController.PostSpecialty(specialty);
                CreatedAtRouteNegotiatedContentResult<SpecialtyModel> specialtyContentResult =
                    (CreatedAtRouteNegotiatedContentResult<SpecialtyModel>)result;
                createdSpecialtyID = specialtyContentResult.Content.SpecialtyID;
            }

            // Create a new test doctor, and get its doctor ID
            using (var doctorController = new DoctorsController())
            {
                var doctor = new DoctorModel
                {
                    FirstName = "Imdoctor",
                    LastName = "Hippocrates",
                    Email = "*****@*****.**",
                    Telephone = "555-1212",
                    CreatedDate = DateTime.Now,
                    SpecialtyID = createdSpecialtyID,
                    Archived = false
                };
                result = doctorController.PostDoctor(doctor);
                CreatedAtRouteNegotiatedContentResult<DoctorModel> doctorContentResult =
                    (CreatedAtRouteNegotiatedContentResult<DoctorModel>)result;
                createdDoctorID = doctorContentResult.Content.DoctorID;
            }

            // Create a new test exam room, and get its exam room ID
            using (var examRoomController = new ExamRoomsController())
            {
                var examRoom = new ExamRoomModel
                {
                    ExamRoomName = "ImexamRoom"
                };
                result = examRoomController.PostExamRoom(examRoom);
                CreatedAtRouteNegotiatedContentResult<ExamRoomModel> examRoomContentResult =
                    (CreatedAtRouteNegotiatedContentResult<ExamRoomModel>)result;
                createdExamRoomID = examRoomContentResult.Content.ExamRoomID;
            }

            // Create a new test doctorCheck, and get its doctorCheckID
            using (var doctorsCheckController = new DoctorsCheckController())
            {
                var doctorsCheck = new DoctorCheckModel
                {
                    DoctorID = createdDoctorID,
                    ExamRoomID = createdExamRoomID,
                    CheckinDateTime = DateTime.Now,
                    CheckoutDateTime = DateTime.Now.AddHours(2)
                };
                result = doctorsCheckController.PostDoctorCheck(doctorsCheck);
                createdContentResult =
                    (CreatedAtRouteNegotiatedContentResult<DoctorCheckModel>)result;
                doctorsCheckIDForTest = createdContentResult.Content.DoctorCheckID;
            }

            //Delete the doctorCheck
            using (var doctorsCheckController = new DoctorsCheckController())
            {
                result = doctorsCheckController.DeleteDoctorCheck(doctorsCheckIDForTest);

                // Verify that HTTP result is OK
                Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<DoctorCheckModel>));
            }

            // Verify that reading deleted doctor check returns result not found
            using (var doctorsCheckController = new DoctorsCheckController())
            {
                result = doctorsCheckController.GetDoctorCheck(doctorsCheckIDForTest);
                Assert.IsInstanceOfType(result, typeof(NotFoundResult));
            }

            // Remove the test doctor from the database with actual deletion, not archiving
            using (MedAgendaDbContext db = new MedAgendaDbContext())
            {
                Doctor dbDoctor = db.Doctors.Find(createdDoctorID);
                db.Doctors.Remove(dbDoctor);
                db.SaveChanges();
            }

            // Delete the test exam room
            using (var SecondExamRoomController = new ExamRoomsController())
            {
                result = SecondExamRoomController.DeleteExamRoom(createdExamRoomID);
            }

            // Delete the test specialty
            using (var specialtyController = new SpecialtiesController())
            {
                result = specialtyController.DeleteSpecialty(createdSpecialtyID);
            }
        }