Пример #1
0
        // The logic to filter service visit based on selected calendar
        private List <ServiceVisitViewModel> FilterByCalendar(List <ServiceVisitViewModel> temp)
        {
            var temporaryVisits = new List <ServiceVisitViewModel>();

            foreach (ServiceVisitViewModel visit in temp)
            {
                switch (this.FilterViewModel.SelectedSchedule)
                {
                case ServiceVisitSchedule.All:
                    temporaryVisits.Add(visit);
                    break;

                case ServiceVisitSchedule.AllScheduled:
                    if (visit.ScheduledDate != null)
                    {
                        temporaryVisits.Add(visit);
                    }
                    break;

                case ServiceVisitSchedule.MonthlyScheduled:
                    if (visit.ScheduledDate != null && ServiceVisitScheduleMethods.IsMonthlyScheduled((System.DateTime)visit.ScheduledDate) == true)
                    {
                        temporaryVisits.Add(visit);
                    }
                    break;

                case ServiceVisitSchedule.TodayScheduled:
                    if (visit.ScheduledDate != null && ServiceVisitScheduleMethods.IsTodayScheduled((System.DateTime)visit.ScheduledDate) == true)
                    {
                        temporaryVisits.Add(visit);
                    }
                    break;

                case ServiceVisitSchedule.Unscheduled:
                    if (visit.ScheduledDate == null)
                    {
                        temporaryVisits.Add(visit);
                    }
                    break;

                case ServiceVisitSchedule.WeeklyScheduled:
                    if (visit.ScheduledDate != null && ServiceVisitScheduleMethods.IsWeeklyScheduled((System.DateTime)visit.ScheduledDate) == true)
                    {
                        temporaryVisits.Add(visit);
                    }
                    break;
                }
            }
            return(temporaryVisits);
        }
Пример #2
0
        public void FilterByMonthlyScheduleTest()
        {
            //Arrange
            ServiceVisitFilterViewModel vm = new ServiceVisitFilterViewModel(visitListViewModel.FullVisitsList);

            //Act
            vm.SelectedSchedule = ServiceVisitSchedule.MonthlyScheduled;
            visitListViewModel.UpdateVisitsBasedOnFilter(vm);

            //Assert
            Boolean isScheduleMatch = true;

            foreach (ServiceVisitViewModel visit in visitListViewModel.Visits)
            {
                if (!ServiceVisitScheduleMethods.IsMonthlyScheduled((System.DateTime)visit.ScheduledDate))
                {
                    isScheduleMatch = false;
                }
            }
            Assert.IsTrue(isScheduleMatch);
        }