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 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); }
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 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); }