// 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); }
public void FilterByWeeklyScheduleTest() { //Arrange ServiceVisitFilterViewModel vm = new ServiceVisitFilterViewModel(visitListViewModel.FullVisitsList); //Act vm.SelectedSchedule = ServiceVisitSchedule.WeeklyScheduled; visitListViewModel.UpdateVisitsBasedOnFilter(vm); //Assert Boolean isScheduleMatch = true; foreach (ServiceVisitViewModel visit in visitListViewModel.Visits) { if (!ServiceVisitScheduleMethods.IsTodayScheduled((System.DateTime)visit.ScheduledDate)) { isScheduleMatch = false; } } Assert.IsTrue(isScheduleMatch); }