Example #1
0
        public void GetAppointments_Success()
        {
            // Act
            var result   = controller.GetAppointments(contactID);
            var response = result as Response <AppointmentViewModel>;

            // Assert
            Assert.IsTrue(response != null, "Response can't be null");
            Assert.IsTrue(response.DataItems != null, "Data items can't be null");
            Assert.IsTrue(response.DataItems.Count > 0, "Atleast one appointment must exists.");
        }
        public void GetAppointments_ShouldGetAll()
        {
            Random        random     = new Random();
            List <Doctor> expDoctors = new List <Doctor>
            {
                new Doctor("FooDoc", "To get", "0"),
                new Doctor("FooDoc", "To get", "1"),
                new Doctor("FooDoc", "To get", "2")
            };
            List <Patient> expPatients = new List <Patient>
            {
                new Patient("FooPatient", "To get0"),
                new Patient("FooPatient", "To get1"),
                new Patient("FooPatient", "To get3"),
                new Patient("FooPatient", "To get4"),
                new Patient("FooPatient", "To get5")
            };
            ICollection <Appointment> expAppointments = new List <Appointment>
            {
                //randomized
                new Appointment(expDoctors[random.Next(0, expDoctors.Count - 1)], expPatients[random.Next(0, expPatients.Count - 1)]),
                new Appointment(expDoctors[random.Next(0, expDoctors.Count - 1)], expPatients[random.Next(0, expPatients.Count - 1)]),
                new Appointment(expDoctors[random.Next(0, expDoctors.Count - 1)], expPatients[random.Next(0, expPatients.Count - 1)])
            };
            ICollection <Appointment> actualAppointments = new List <Appointment>();

            Assert.True(_controller.GetAppointments().Count == 0);
            foreach (var appointment in expAppointments)
            {
                _controller.AddAppointment(appointment);
            }

            actualAppointments = _controller.GetAppointments();

            Assert.True(expAppointments.SequenceEqual(actualAppointments));
        }
        internal async Task UpdateAppointmentsAsync()
        {
            List <Appointment> appointments = null;

            using (_controller = new AppointmentController())
                await Task.Run(() => appointments = (List <Appointment>) _controller.GetAppointments());

            if (appointments != null)
            {
                lock (_appointments)
                    lock (AppointmentModels)
                    {
                        _appointments.Clear();
                        AppointmentModels.Clear();
                        foreach (var appointment in appointments)
                        {
                            _appointments.Add(appointment);
                            AppointmentModels.Add(new AppointmentModel(appointment));
                        }
                    }
            }
        }