Example #1
0
        public ScheduleEventStatisticsResponseDTO GetScheduleStatistics()
        {
            try
            {
                List <ScheduleEvent> listOfEvents = _eventRepository.GetAll().ToList();

                Dictionary <Guid, List <ScheduleEvent> > mapOfEventsPerSession = this.GenerateDictionaryPerSession(listOfEvents);

                ScheduleEventStatisticsResponseDTO scheduleStatisticsResponseDTO = new ScheduleEventStatisticsResponseDTO();
                scheduleStatisticsResponseDTO.PercentOfSuccessfulCreating   = this.GetPercentOfSuccessfulCreating(mapOfEventsPerSession);
                scheduleStatisticsResponseDTO.AverageCreatingTime           = this.GetAverageCreatingTime(mapOfEventsPerSession);
                scheduleStatisticsResponseDTO.AverageNotCreatedTime         = this.GetAverageNotCreatedTime(mapOfEventsPerSession);
                scheduleStatisticsResponseDTO.StepWherePatientsQuit         = this.GetStepWherePatientsMostQuit(mapOfEventsPerSession);
                scheduleStatisticsResponseDTO.NumberOfCreatedAppointment    = this.GetNumberOfCreatedAppoitment(mapOfEventsPerSession);
                scheduleStatisticsResponseDTO.NumberOfNotCreatedAppointment = this.GetNumberNotCreatedAppoitment(mapOfEventsPerSession);
                scheduleStatisticsResponseDTO.AverageTimeOnSpecialization   = this.GetAverageTimeOnSpecialization(mapOfEventsPerSession);
                scheduleStatisticsResponseDTO.AverageTimeOnDoctors          = this.GetAverageTimeOnDoctors(mapOfEventsPerSession);
                scheduleStatisticsResponseDTO.AverageTimeOnChooseDate       = this.GetAverageTimeOnChooseDate(mapOfEventsPerSession);
                scheduleStatisticsResponseDTO.AverageTimeOnChoosePeriod     = this.GetAverageTimeOnChoosePeriod(mapOfEventsPerSession);

                return(scheduleStatisticsResponseDTO);
            }catch (Exception e)
            {
                throw new InternalServerErrorException();
            }
        }
        public void Get_schedule_statistics()
        {
            eventRepository.GetAll().Returns(this.GetScheduleEvents());

            ScheduleEventStatisticsResponseDTO scheduleStatisticsDTO = scheduleEventService.GetScheduleStatistics();

            Assert.Equal(50, scheduleStatisticsDTO.PercentOfSuccessfulCreating);
            Assert.Equal(10.75, scheduleStatisticsDTO.AverageCreatingTime);
            Assert.Equal(1, scheduleStatisticsDTO.StepWherePatientsQuit);
            Assert.Equal(4, scheduleStatisticsDTO.NumberOfCreatedAppointment);
            Assert.Equal(2.2, scheduleStatisticsDTO.AverageTimeOnSpecialization);
            Assert.Equal(1.8, scheduleStatisticsDTO.AverageTimeOnDoctors);
            Assert.Equal(1.33, scheduleStatisticsDTO.AverageTimeOnChooseDate, 2);
            Assert.Equal(2.8, scheduleStatisticsDTO.AverageTimeOnChoosePeriod);
            Assert.Equal(4, scheduleStatisticsDTO.NumberOfNotCreatedAppointment);
            Assert.Equal(4.75, scheduleStatisticsDTO.AverageNotCreatedTime);
        }