public void SupportsMultipleServicesAtTheSameTime() { var stop1 = CreateScheduleStop(TestSchedules.Ten); var stop2 = CreateScheduleStop(TestSchedules.Ten); var schedule = new PublicSchedule(TestStations.Surbiton, TimesToUse.Arrivals, Time.EarlierLaterComparer); schedule.AddService(CreateServiceTime(stop1)); schedule.AddService(CreateServiceTime(stop2)); var services = schedule.GetServices(TestSchedules.Ten); Assert.Equal(2, services.Length); }
public void CountOfUniqueTimes() { var stop1 = CreateScheduleStop(TestSchedules.Ten); var stop2 = CreateScheduleStop(TestSchedules.TenThirty); var stop3 = CreateScheduleStop(TestSchedules.Ten); var schedule = new PublicSchedule(TestStations.Surbiton, TimesToUse.Arrivals, Time.EarlierLaterComparer); schedule.AddService(CreateServiceTime(stop1)); schedule.AddService(CreateServiceTime(stop2)); schedule.AddService(CreateServiceTime(stop3)); Assert.Equal(2, schedule.Count); }
public void ReturnsTimeAndServicesAtIndex() { var stop1 = CreateScheduleStop(TestSchedules.Ten); var stop2 = CreateScheduleStop(TestSchedules.TenThirty); var schedule = new PublicSchedule(TestStations.Surbiton, TimesToUse.Arrivals, Time.EarlierLaterComparer); schedule.AddService(CreateServiceTime(stop1)); schedule.AddService(CreateServiceTime(stop2)); var pair = schedule.ValuesAt(1); Assert.Equal(TestSchedules.TenThirty, pair.time); Assert.Equal(stop2.Service, pair.services.Single()); }
public void AddServiceOnlyWhenPublic() { var publicStop = CreateScheduleStop(TestSchedules.Ten); var workingStop = CreateScheduleStop(TestSchedules.TenThirty); workingStop.Arrival = Time.NotValid; var schedule = new PublicSchedule(TestStations.Surbiton, TimesToUse.Arrivals, Time.EarlierLaterComparer); schedule.AddService(CreateServiceTime(publicStop)); schedule.AddService(CreateServiceTime(workingStop)); Assert.NotEmpty(schedule.GetServices(TestSchedules.Ten)); Assert.Empty(schedule.GetServices(TestSchedules.TenThirty)); }
public void WhenHaveTwoAtSameTimeJustOnePlusOneDay() { var twelvethirty = new Time(new TimeSpan(0, 30, 0)); var twelvethirtyPlusOne = twelvethirty.Add(Time.OneDay); var services = new[] { CreateScheduleStop(twelvethirtyPlusOne, "NextDay"), CreateScheduleStop(twelvethirty, "Today") }; var schedule = new PublicSchedule(TestStations.Surbiton, TimesToUse.Arrivals, Time.EarlierLaterComparer); foreach (var service in services) { schedule.AddService(CreateServiceTime(service)); } var searchAt = Aug5.AddMinutes(1); var found = schedule.FindServices(searchAt, GathererConfig.OneService); Assert.Equal(2, found.Length); Assert.Collection(found, s => { Assert.Equal(Aug4, s.On); }, s => { Assert.Equal(Aug5, s.On); }); }
public void ServiceDateIsDayBeforeWhenTimeIsPlusOneDay() { var one = new Time(new TimeSpan(1, 0, 0)); var twelvethirty = new Time(new TimeSpan(0, 30, 0)); twelvethirty = twelvethirty.Add(Time.OneDay); var services = new[] { CreateScheduleStop(one), CreateScheduleStop(twelvethirty) }; var schedule = new PublicSchedule(TestStations.Surbiton, TimesToUse.Arrivals, Time.EarlierLaterComparer); foreach (var service in services) { schedule.AddService(CreateServiceTime(service)); } var searchAt = Aug5.AddMinutes(1); var found = schedule.FindServices(searchAt, GathererConfig.OneService); Assert.Equal(Aug4, found[0].Service.On); }
public void ReturnNearestWhenHaveVersionGoesOverMidnight() { var one = new Time(new TimeSpan(1, 0, 0)); var twelvethirty = new Time(new TimeSpan(0, 30, 0)); twelvethirty = twelvethirty.Add(Time.OneDay); var services = new[] { CreateScheduleStop(one), CreateScheduleStop(twelvethirty) }; var schedule = new PublicSchedule(TestStations.Surbiton, TimesToUse.Arrivals, Time.EarlierLaterComparer); foreach (var service in services) { schedule.AddService(CreateServiceTime(service)); } var searchAt = Aug5.AddMinutes(1); var found = schedule.FindServices(searchAt, GathererConfig.OneService); Assert.Equal(services[1].Schedule, found[0].Service.Details); }
private (PublicSchedule schedule, ScheduleStop[] stops) CreateSchedule(ICalendar calendar = null) { var services = new[] { CreateScheduleStop(TestSchedules.Ten, calendar: calendar), CreateScheduleStop(TestSchedules.TenThirty, calendar: calendar), CreateScheduleStop(new Time(new TimeSpan(11, 0, 0)), calendar: calendar) }; var schedule = new PublicSchedule(TestStations.Surbiton, TimesToUse.Arrivals, Time.EarlierLaterComparer); foreach (var service in services) { schedule.AddService(CreateServiceTime(service)); } return(schedule, services); }
public void CanReturnOnlyBeforeResults() { var services = new[] { CreateScheduleStop(TestSchedules.Ten), CreateScheduleStop(TestSchedules.TenThirty), }; var schedule = new PublicSchedule(TestStations.Surbiton, TimesToUse.Arrivals, Time.EarlierLaterComparer); foreach (var service in services) { schedule.AddService(CreateServiceTime(service)); } var searchAt = Aug5.AddHours(10).AddMinutes(1); var found = schedule.FindServices(searchAt, GathererConfig.OneBefore); Assert.Equal(services[0].Schedule, found[0].Service.Details); }