// GET: api/Consultations
        public HttpResponseMessage GetConsultations()
        {
            var consultationList = _manager.GetConsultations();

            return(consultationList != null?Request.CreateResponse(HttpStatusCode.OK, consultationList) :
                       Request.CreateResponse(HttpStatusCode.NoContent));
        }
Пример #2
0
        public void GetConsultations_VerifyConsultationDateCalculation()
        {
            List <Patient> newPatients = CreatTestPatients();

            foreach (bool isPaitentAdded in newPatients.Select(patient => _manager.RegisterPatient(patient)))
            {
                Assert.IsTrue(isPaitentAdded);
            }

            //At this point, we have three cancer patients registered, two of them needs Advanced treatment machine, and one needs either Advance or Simple
            //treatment machine. Therefore patient Daisy will have to be scheduled a couple of days from the
            //registered date.

            var patients = _manager.GetRegisteredPatients().ToList();

            Assert.IsNotNull(patients);
            Assert.AreEqual(patients.Count, 3);

            var consultations = _manager.GetConsultations().ToList();

            Assert.IsNotNull(consultations);
            Assert.AreEqual(consultations.Count, 3);

            Consultation consultation = consultations.First(c => c.Patient.FirstName == "Lily");

            Assert.IsNotNull(consultation);
            Assert.AreEqual((consultation.ConsultationDate - consultation.RegistrationDate).TotalDays, 1);

            consultation = consultations.First(c => c.Patient.FirstName == "Poppy");
            Assert.IsNotNull(consultation);
            Assert.AreEqual((consultation.ConsultationDate - consultation.RegistrationDate).TotalDays, 1);

            consultation = consultations.First(c => c.Patient.FirstName == "Daisy");
            Assert.IsNotNull(consultation);
            Assert.AreEqual((consultation.ConsultationDate - consultation.RegistrationDate).TotalDays, 2);

            //Clear registered patients so that individual unit test has control over patient and consultation data.
            PatientSchedulerContext.Patients.Clear();
            PatientSchedulerContext.Consultations.Clear();
        }