Esempio n. 1
0
        public void TestDeleteLastAppointment()
        {
            Appointment appt = new Appointment();

            try
            {
                List <Appointment> apptList = AppointmentSchedulingServices.GetAllAppointments();

                if (apptList != null && apptList.Count > 0)
                {
                    appt = apptList[apptList.Count - 1];

                    bool result = AppointmentSchedulingServices.DeleteAppointment(appt.ID);

                    Assert.IsTrue(result, "Appointment deleted.");
                }
                else
                {
                    Assert.Fail("Appointment List was Empty");
                }
            }
            catch (AssertFailedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception thrown --> " + ex.ToString());
            }
        }
Esempio n. 2
0
        public void TestUpperOverlapOnAddAppointment()
        {
            Appointment appt = new Appointment();

            try
            {
                List <Appointment> apptList = AppointmentSchedulingServices.GetAllAppointments();

                if (apptList != null && apptList.Count > 0)
                {
                    appt           = apptList[apptList.Count - 1];
                    appt.StartTime = appt.StartTime.Value.AddMinutes(15);
                    appt.EndTime   = appt.EndTime.AddMinutes(15);
                    bool result = AppointmentSchedulingServices.AddAppointment(appt);
                }
                else
                {
                    Assert.Fail("Appointment List was Empty");
                }
            }
            catch (AssertFailedException)
            {
                throw;
            }
            catch (InvalidRangeException)
            {
                Assert.IsTrue(true, "Invalid range expected.");
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception thrown --> " + ex.ToString());
            }
        }
Esempio n. 3
0
        public void TestUpdateLastAppointment()
        {
            Appointment appt = new Appointment();

            try
            {
                List <Appointment> apptList = AppointmentSchedulingServices.GetAllAppointments();

                if (apptList != null && apptList.Count > 0)
                {
                    appt = apptList[apptList.Count - 1];

                    appt.Comments  = "Appointment updated";
                    appt.StartTime = DateTime.Now.AddDays(1);
                    appt.EndTime   = DateTime.Now.AddDays(1).AddMinutes(30);

                    bool result = AppointmentSchedulingServices.UpdateAppointment(appt);

                    Assert.IsTrue(result, "Appointment updated.");
                }
                else
                {
                    Assert.Fail("Appointment List was Empty");
                }
            }
            catch (AssertFailedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception thrown --> " + ex.ToString());
            }
        }
Esempio n. 4
0
        /// <summary>
        /// The ListAppointments operation maps to HTTP GET method for fetching appointments.
        /// </summary>
        /// <param name="startTime">Start time</param>
        /// <param name="endTime">End time</param>
        /// <returns>Success flag, error message and appointment list.</returns>
        public ApiResponse ListAppointments(String startTime, String endTime)
        {
            List <AppointmentContract> results = new List <AppointmentContract>();
            List <Appointment>         appts   = null;
            ApiResponse response = new ApiResponse();
            bool        success  = false;
            DateTime    startDt;
            DateTime    endDt;

            try
            {
                DateTime.TryParse(startTime, out startDt);
                DateTime.TryParse(endTime, out endDt);

                if (String.IsNullOrEmpty(startTime) && String.IsNullOrEmpty(endTime))
                {
                    appts = AppointmentSchedulingServices.GetAllAppointments();
                }
                else if ((!String.IsNullOrEmpty(startTime) && !String.IsNullOrEmpty(endTime)) &&
                         (startDt != null && endDt != null) && (startDt <= endDt))
                {
                    appts = AppointmentSchedulingServices.GetAppointmentsByDateRange(startDt, endDt);
                }
                else
                {
                    response.ErrorMessage = "Invalid filters";
                }

                if (String.IsNullOrEmpty(response.ErrorMessage) && appts != null)
                {
                    foreach (Appointment appt in appts)
                    {
                        AppointmentContract tmpApptmnt = new AppointmentContract();

                        tmpApptmnt.ID        = appt.ID.ToString();
                        tmpApptmnt.StartTime = appt.StartTime.ToString();
                        tmpApptmnt.EndTime   = appt.EndTime.ToString();
                        tmpApptmnt.FirstName = appt.FirstName;
                        tmpApptmnt.LastName  = appt.LastName;
                        tmpApptmnt.Comments  = appt.Comments;

                        results.Add(tmpApptmnt);
                    }

                    success = true;
                }
            }
            catch (Exception e)
            {
                response.ErrorMessage = "Error listing appointments --> " + e.Message.ToString();
            }
            finally
            {
                response.Success      = success.ToString();
                response.Appointments = (results.Count > 0) ? results : null;
            }

            return(response);
        }
Esempio n. 5
0
        public void TestGetAllAppointments()
        {
            List <Appointment> apptList;

            try
            {
                apptList = AppointmentSchedulingServices.GetAllAppointments();

                Assert.IsNotNull(apptList, "Appointment list not null.");
                Assert.IsTrue(apptList.Count > 0, "One or more elements found this year.");
            }
            catch (AssertFailedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception thrown --> " + ex.ToString());
            }
        }