Beispiel #1
0
        public void GetsTocSchedulesHandlesIndividualDodgyServicesAndLogsAsWarning()
        {
            var logger    = Substitute.For <ILogger>();
            var timetable = CreateTimetable(logger);

            var schedule = TestSchedules.CreateScheduleInTimetable(timetable, calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Monday));
            var start    = TestSchedules.Ten;
            var stops    = new ScheduleLocation[]
            {
                TestScheduleLocations.CreatePass(TestStations.Vauxhall, start.AddMinutes(10)),
                TestScheduleLocations.CreatePass(TestStations.ClaphamJunction, start.AddMinutes(20)),
                TestScheduleLocations.CreatePass(TestStations.Wimbledon, start.AddMinutes(20)),
            };
            var dodgySchedule = TestSchedules.CreateScheduleInTimetable(timetable, timetableId: "D11111", calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Monday), stops: stops);
            var schedule3     = TestSchedules.CreateScheduleInTimetable(timetable, timetableId: "X98765", calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Monday));

            var found     = timetable.GetSchedulesByToc("VT", MondayAugust12, Time.Midnight);
            var schedules = found.services.Select(s => s.Details).ToArray();

            Assert.Contains <ISchedule>(schedule, schedules);
            Assert.Contains <ISchedule>(schedule3, schedules);
            Assert.All(found.services, s => { Assert.Equal(MondayAugust12, s.On); });

            logger.Received().Warning(Arg.Any <InvalidOperationException>(), Arg.Any <string>(), Arg.Any <IService>());
        }
Beispiel #2
0
        public void IsStopAtAlwaysFalseForPassingPoint(TimesToUse arrivalOrDeparture)
        {
            var stop = TestScheduleLocations.CreatePass(Surbiton, TestSchedules.Ten);
            var spec = CreateFindSpec(TestSchedules.Ten, arrivalOrDeparture);

            Assert.False(stop.IsStopAt(spec));
        }
        public void AddDayToSchedulePass()
        {
            var scheduleLocation = TestScheduleLocations.CreatePass(TestStations.Surbiton, Test);

            scheduleLocation.AddDay(Start);

            Assert.Equal(Expected, scheduleLocation.PassesAt);
        }
        public void StartsBeforeThrowsInvalidOperationExceptionWhenNoDepartures()
        {
            var start = TestSchedules.Ten;
            var stops = new ScheduleLocation[]
            {
                TestScheduleLocations.CreatePass(TestStations.Vauxhall, start.AddMinutes(10)),
                TestScheduleLocations.CreatePass(TestStations.ClaphamJunction, start.AddMinutes(20)),
                TestScheduleLocations.CreatePass(TestStations.Wimbledon, start.AddMinutes(20)),
            };
            var service = TestSchedules.CreateScheduleWithService(stops: stops).Service;

            Assert.Throws <InvalidOperationException>(() => service.StartsBefore(Time.StartRailDay));
        }
        public void LocationHasNoEntryForPassing()
        {
            var locations = new[]
            {
                (ScheduleLocation)TestScheduleLocations.CreateOrigin(TestStations.Surbiton, TestSchedules.Ten),
                TestScheduleLocations.CreatePass(TestStations.ClaphamJunction, TenFifteen),
                TestScheduleLocations.CreateDestination(TestStations.Waterloo, TestSchedules.TenThirty)
            };

            var testSchedule = TestSchedules.CreateScheduleWithService(stops: locations);

            var passing = locations[1].Station.Timetable;

            AssertNoArrivalTime(passing, TenFifteen);
            AssertNoDepartureTime(passing, TenFifteen);
        }
Beispiel #6
0
        public void MapSchedulePass()
        {
            var mapper = ToViewProfileConfiguration.CreateMapper();

            var input = TestScheduleLocations.CreatePass(
                TestLocations.CLPHMJN,
                new Time(TestTime.Ten));

            var output = Map(input);

            Assert.Equal("CLJ", output.Location.ThreeLetterCode);
            var expected = TestDate.Add(TestTime.Ten);

            Assert.Equal(expected, output.PassesAt);
            Assert.Equal("", output.Platform);
            Assert.Empty(output.Activities);
            Assert.Null(output.Arrival);
            Assert.Null(output.Departure);
        }
        public void SchedulePassIsNotAStop()
        {
            var scheduleLocation = TestScheduleLocations.CreatePass(TestStations.Surbiton, Test);

            Assert.Equal(PublicStop.No, scheduleLocation.AdvertisedStop);
        }