コード例 #1
0
        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); });
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }