public void GetsTocSchedulesRunningOnRailDay() { var timetable = CreateTimetable(); var schedule = TestSchedules.CreateScheduleInTimetable(timetable, calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Monday)); var schedule2 = TestSchedules.CreateScheduleInTimetable(timetable, calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Tuesday)); var startsRailDay = TestSchedules.CreateScheduleInTimetable(timetable, timetableId: "X98765", calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Monday | DaysFlag.Tuesday), stops: TestSchedules.CreateThreeStopSchedule(Time.StartRailDay)); var startsBeforeRailDay = TestSchedules.CreateScheduleInTimetable(timetable, timetableId: "X98764", calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Monday | DaysFlag.Tuesday), stops: TestSchedules.CreateThreeStopSchedule(Time.StartRailDay.AddMinutes(-1))); var startsAfterRailDay = TestSchedules.CreateScheduleInTimetable(timetable, timetableId: "X98766", calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Monday | DaysFlag.Tuesday), stops: TestSchedules.CreateThreeStopSchedule(Time.StartRailDay.AddMinutes(1))); var found = timetable.GetSchedulesByToc("VT", MondayAugust12, Time.StartRailDay); var startDaySchedule = found.services.Single(s => s.Details == startsRailDay); Assert.Equal(MondayAugust12, startDaySchedule.On); var startAfterDaySchedule = found.services.Single(s => s.Details == startsAfterRailDay); Assert.Equal(MondayAugust12, startAfterDaySchedule.On); var startBeforeDaySchedule = found.services.Single(s => s.Details == startsBeforeRailDay); Assert.Equal(TuesdayAugust13, startBeforeDaySchedule.On); Assert.Equal(4, found.services.Length); }
private ScheduleLocation[] CreateMainStops() { var mainStops = TestSchedules.CreateThreeStopSchedule(TestSchedules.Ten); mainStops[2] = TestScheduleLocations.CreateStop(TestStations.Vauxhall, TestSchedules.TenTwenty); // Make Vauxhall a stop return(mainStops); }
public void StopIsNextDay(Time startTime, bool expected) { var stops = TestSchedules.CreateThreeStopSchedule(startTime); var service = TestSchedules.CreateService(stops: stops); var clapham = service.Details.Locations[1]; var stop = new ResolvedServiceStop(service, clapham); Assert.Equal(expected, stop.IsNextDay(true)); }
private Association CreateJoinServices(ScheduleLocation[] mainStops = null) { mainStops = mainStops ?? TestSchedules.CreateThreeStopSchedule(TestSchedules.Ten); var main = TestSchedules.CreateScheduleWithService("X12345", retailServiceId: "VT123401", stops: mainStops).Service; var associated = TestSchedules.CreateScheduleWithService("A98765", retailServiceId: "VT123402", stops: TestSchedules.CreateWokingClaphamSchedule(TestSchedules.NineForty)).Service; var association = TestAssociations.CreateAssociationWithServices(main, associated); return(association); }
private Association CreateAssociation(AssociationCategory category, ScheduleLocation[] mainStops = null) { mainStops = mainStops ?? TestSchedules.CreateThreeStopSchedule(TestSchedules.Ten); var main = TestSchedules.CreateScheduleWithService("X12345", retailServiceId: "VT123401", stops: mainStops).Service; var associated = TestSchedules.CreateScheduleWithService("A98765", retailServiceId: "VT123402", stops: TestSchedules.CreateClaphamWokingSchedule(TestSchedules.TenTwentyFive)).Service; var association = TestAssociations.CreateAssociationWithServices(main, associated, category: category); return(association); }
public void OnlyDepartureNextDay(bool useDeparture, bool expected) { var stops = TestSchedules.CreateThreeStopSchedule(new Time(new TimeSpan(23, 40, 0))); var service = TestSchedules.CreateService(stops: stops); var clapham = service.Details.Locations[1] as ScheduleStop; clapham.Departure = new Time(new TimeSpan(0, 5, 0)).AddDay(); var stop = new ResolvedServiceStop(service, clapham); Assert.Equal(expected, stop.IsNextDay(useDeparture)); }
public void DoesNotAddTocIfDoesNotStop() { var test = TestStations.Waterloo; var service = new CifService("X12345", Substitute.For <ILogger>()); var schedule = TestSchedules.CreateSchedule(timetableId: "X12345", service: service, stops: TestSchedules.CreateThreeStopSchedule(TestSchedules.Ten)); var stop = schedule.Locations[2]; // Pass test.Add(stop); Assert.Empty(test.TocServices); }
private CifSchedule CreateServiceStartingAt(Time startsAt) { var stops = TestSchedules.CreateThreeStopSchedule(startsAt); return(TestSchedules.CreateScheduleWithService(stops: stops)); }