コード例 #1
0
        public void MapStop()
        {
            var mapper = ToViewProfileConfiguration.CreateMapper();

            var stopDate = TestDate.AddDays(1);
            var input    = new ResolvedStop(
                TestScheduleLocations.CreateStop(
                    TestLocations.Surbiton,
                    new Time(TestTime.Ten)),
                stopDate);


            var output = Map(input);

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

            Assert.Equal(expected, output.Arrival);
            var expectedDeparture = expected.AddMinutes(1);

            Assert.Equal(expectedDeparture, output.Departure);
            Assert.Equal("10", output.Platform);
            Assert.Equal("T", output.Activities);
            Assert.Null(output.PassesAt);
        }
コード例 #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));
        }
コード例 #3
0
        private ScheduleStop CreateScheduleStop()
        {
            var stop = TestScheduleLocations.CreateStop(TestStations.Surbiton, TestSchedules.Ten);

            TestSchedules.CreateScheduleWithService(stops: new ScheduleLocation[] { stop });
            return(stop);
        }
コード例 #4
0
        public void IsStopAtIfLocationMatches(Location location, bool expected)
        {
            var stop = TestScheduleLocations.CreateStop(location, TestSchedules.Ten);
            var spec = CreateFindSpec(TestSchedules.Ten, TimesToUse.Arrivals, ClaphamJunction);

            Assert.Equal(expected, stop.IsStopAt(spec));
        }
コード例 #5
0
        public void GoesToWorksWithSplitsWhereMainStartsAtSplitPoint()
        {
            //  Start at Clapham
            var mainStops = CreateMainStops();

            mainStops = new [] {
                TestScheduleLocations.CreateOrigin(TestStations.ClaphamJunction, TestSchedules.TenTen),
                mainStops[2],
                mainStops[3]
            };
            var association = CreateSplitServices(mainStops);

            var at    = new StopSpecification(TestStations.ClaphamJunction, TestSchedules.TenTen, MondayAugust12, TimesToUse.Departures);
            var found = association.Main.Service.TryFindScheduledStop(at, out var mainStop);

            // Both trains start at Clapham so actually whole journey on split
            // Using main stop fails
            Assert.True(mainStop.GoesTo(TestStations.Woking));
            Assert.NotNull(mainStop.FoundToStop);
            Assert.True(mainStop.Association.IsIncluded);

            at    = new StopSpecification(TestStations.ClaphamJunction, TestSchedules.TenTwentyFive, MondayAugust12, TimesToUse.Departures);
            found = association.Associated.Service.TryFindScheduledStop(at, out var associationStop);

            // Using Association works
            Assert.True(associationStop.GoesTo(TestStations.Woking));
            Assert.NotNull(associationStop.FoundToStop);
            Assert.False(associationStop.Association.IsIncluded);
        }
コード例 #6
0
        private ScheduleLocation[] CreateMainStops(Time departs)
        {
            var mainStops = TestSchedules.CreateFourStopSchedule(departs);

            mainStops[3] = TestScheduleLocations.CreateStop(TestStations.Vauxhall, TestSchedules.TenTwenty);    // Make Vauxhall a stop
            return(mainStops);
        }
コード例 #7
0
        public void IsStopAtWorksForOrigin(Time stopDeparture, Time findTime, TimesToUse arrivalOrDeparture, bool expected)
        {
            var stop = TestScheduleLocations.CreateOrigin(Surbiton, stopDeparture);
            var spec = CreateFindSpec(findTime, arrivalOrDeparture);

            Assert.Equal(expected, stop.IsStopAt(spec));
        }
コード例 #8
0
        private ScheduleLocation[] CreateMainStops()
        {
            var mainStops = TestSchedules.CreateThreeStopSchedule(TestSchedules.Ten);

            mainStops[2] = TestScheduleLocations.CreateStop(TestStations.Vauxhall, TestSchedules.TenTwenty);    // Make Vauxhall a stop
            return(mainStops);
        }
コード例 #9
0
        public void AddDayToSchedulePass()
        {
            var scheduleLocation = TestScheduleLocations.CreatePass(TestStations.Surbiton, Test);

            scheduleLocation.AddDay(Start);

            Assert.Equal(Expected, scheduleLocation.PassesAt);
        }
コード例 #10
0
        private ScheduleStop CreateScheduleStop(Time time, string timetableId = "X12345", ICalendar calendar = null)
        {
            calendar = calendar ?? TestSchedules.EverydayAugust2019;
            var stop = TestScheduleLocations.CreateStop(TestStations.Surbiton, time);

            TestSchedules.CreateScheduleWithService(timetableId: timetableId, calendar: calendar, stops: new ScheduleLocation[] { stop });
            return(stop);
        }
コード例 #11
0
        public void DoNotAddDay()
        {
            var scheduleLocation = TestScheduleLocations.CreateOrigin(TestLocations.Surbiton, Start);

            scheduleLocation.AddDay(Start);

            Assert.Equal(Start, scheduleLocation.Departure);
            Assert.Equal(Start.Add(ThirtySeconds), scheduleLocation.WorkingDeparture);
        }
コード例 #12
0
        public void AddDayToScheduleOrigin()
        {
            var scheduleLocation = TestScheduleLocations.CreateOrigin(TestLocations.Surbiton, Test);

            scheduleLocation.AddDay(Start);

            Assert.Equal(Expected, scheduleLocation.Departure);
            Assert.Equal(Expected.Add(ThirtySeconds), scheduleLocation.WorkingDeparture);
        }
コード例 #13
0
        public void AddDayToScheduleDestination()
        {
            var scheduleLocation = TestScheduleLocations.CreateDestination(TestStations.Surbiton, Test);

            scheduleLocation.AddDay(Start);

            Assert.Equal(Expected, scheduleLocation.Arrival);
            Assert.Equal(Expected.Subtract(ThirtySeconds), scheduleLocation.WorkingArrival);
        }
コード例 #14
0
        public void IsStopAtWorksForSetdownOnly(Time stopArrival, Time findTime, TimesToUse arrivalOrDeparture, bool expected)
        {
            var stop = TestScheduleLocations.CreateSetdownOnlyStop(Surbiton, stopArrival);

            stop.WorkingDeparture = stopArrival.AddMinutes(1);
            var spec = CreateFindSpec(findTime, arrivalOrDeparture);

            Assert.Equal(expected, stop.IsStopAt(spec));
        }
コード例 #15
0
        public void OnlyIncludeStopsWhereAdvertisedStopIsRight(string activity, bool useArrivals, bool expected)
        {
            var stop = TestScheduleLocations.CreateStop(ClaphamJunction, TestSchedules.Ten, activity);

            var arrivalsDepartures = useArrivals ? TimesToUse.Arrivals : TimesToUse.Departures;
            var findAt             = useArrivals ? TestSchedules.Ten : TestSchedules.Ten.AddMinutes(1);
            var spec = CreateFindSpec(findAt, arrivalsDepartures, ClaphamJunction);

            Assert.Equal(expected, stop.IsStopAt(spec));
        }
コード例 #16
0
        public void AddDayToScheduleStop()
        {
            var scheduleLocation = TestScheduleLocations.CreateStop(TestLocations.Surbiton, Test);

            scheduleLocation.AddDay(Start);

            Assert.Equal(Expected, scheduleLocation.Arrival);
            Assert.Equal(Expected.Subtract(ThirtySeconds), scheduleLocation.WorkingArrival);
            Assert.Equal(Expected.Add(OneMinute), scheduleLocation.Departure);
            Assert.Equal(Expected.Add(ThirtySeconds), scheduleLocation.WorkingDeparture);
        }
コード例 #17
0
        public void ReturnNullWhenInvalidTime()
        {
            var mapper = ToViewProfileConfiguration.CreateMapper();

            var input = TestScheduleLocations.CreateStop(
                TestLocations.Surbiton,
                Time.NotValid);

            var output = Map(input);

            Assert.Null(output.Arrival);
        }
コード例 #18
0
        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));
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        public void ComesFromWorksWithJoinsWhereMainEndsAtJoinPoint()
        {
            //  Ends at Clapham
            var mainStops = CreateMainStops();

            mainStops = new [] {
                mainStops[0],
                TestScheduleLocations.CreateDestination(TestStations.ClaphamJunction, TestSchedules.TenFifteen)
            };
            var association = CreateJoinServices(mainStops);

            var at    = new StopSpecification(TestStations.ClaphamJunction, TestSchedules.TenFifteen, MondayAugust12, TimesToUse.Arrivals);
            var found = association.Main.Service.TryFindScheduledStop(at, out var stop);

            Assert.True(stop.ComesFrom(TestStations.Woking));
            Assert.NotNull(stop.FoundFromStop);
            Assert.True(stop.Association.IsIncluded);
        }
コード例 #21
0
        public void GoesToWorksWithSplitsWhereMainTerminatesAtSplitPoint()
        {
            //  Stop at Clapham
            var mainStops = CreateMainStops();

            mainStops = new [] {
                mainStops[0],
                TestScheduleLocations.CreateDestination(TestStations.ClaphamJunction, TestSchedules.TenFifteen)
            };
            var association = CreateSplitServices(mainStops);

            var at    = new StopSpecification(TestStations.Surbiton, TestSchedules.Ten, MondayAugust12, TimesToUse.Departures);
            var found = association.Main.Service.TryFindScheduledStop(at, out var stop);

            Assert.True(stop.GoesTo(TestStations.Woking));
            Assert.NotNull(stop.FoundToStop);
            Assert.True(stop.Association.IsIncluded);
        }
コード例 #22
0
        public void ComesFromWorksWithSplitsWhereMainStartsAtSplitPoint()
        {
            //  Start at Clapham
            var mainStops = CreateMainStops();

            mainStops = new [] {
                TestScheduleLocations.CreateOrigin(TestStations.ClaphamJunction, TestSchedules.TenTen),
                mainStops[3]
            };
            var association = CreateSplitServices(mainStops);

            var at    = new StopSpecification(TestStations.Woking, TestSchedules.TenFiftyFive, MondayAugust12, TimesToUse.Arrivals);
            var found = association.Associated.Service.TryFindScheduledStop(at, out var stop);

            Assert.True(stop.ComesFrom(TestStations.ClaphamJunction));
            Assert.NotNull(stop.FoundFromStop);
            Assert.False(stop.Association.IsIncluded);
        }
コード例 #23
0
        public void GoesToWorksWithJoinsWhereMainStartsAtJoinPoint()
        {
            //  Starts at Clapham
            var mainStops = CreateMainStops();

            mainStops = new [] {
                TestScheduleLocations.CreateOrigin(TestStations.ClaphamJunction, TestSchedules.TenFifteen),
                mainStops[2],
                mainStops[3]
            };
            var association = CreateJoinServices(mainStops);

            var at    = new StopSpecification(TestStations.Woking, TestSchedules.NineForty, MondayAugust12, TimesToUse.Departures);
            var found = association.Associated.Service.TryFindScheduledStop(at, out var stop);

            Assert.True(stop.GoesTo(TestStations.Waterloo));
            Assert.NotNull(stop.FoundToStop);
            Assert.True(stop.Association.IsIncluded);
        }
コード例 #24
0
        public void GoesToWorksWithJoinsWhereMainStopsAtJoinPoint()
        {
            //  Ends at Clapham
            var mainStops = CreateMainStops();

            mainStops = new [] {
                mainStops[0],
                TestScheduleLocations.CreateDestination(TestStations.ClaphamJunction, TestSchedules.TenFifteen)
            };
            var association = CreateJoinServices(mainStops);

            var at    = new StopSpecification(TestStations.Woking, TestSchedules.NineForty, MondayAugust12, TimesToUse.Departures);
            var found = association.Associated.Service.TryFindScheduledStop(at, out var stop);

            // Neither train goes beyond Clapham so actually whole journey on join
            Assert.True(stop.GoesTo(TestStations.ClaphamJunction));
            Assert.NotNull(stop.FoundToStop);
            Assert.False(stop.Association.IsIncluded);
        }
コード例 #25
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);
        }
コード例 #26
0
        public void MapScheduleDestination()
        {
            var mapper = ToViewProfileConfiguration.CreateMapper();

            var input = TestScheduleLocations.CreateDestination(
                TestLocations.WaterlooMain,
                new Time(TestTime.Ten));

            var output = Map(input);

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

            Assert.Equal(expected, output.Arrival);
            Assert.Equal("2", output.Platform);
            Assert.Equal("TF", output.Activities);
            Assert.Null(output.PassesAt);
            Assert.Null(output.Departure);
        }
コード例 #27
0
        public void LocationHasArrivalOnlyForSetdownOnlyStop()
        {
            var locations = new[]
            {
                (ScheduleLocation)TestScheduleLocations.CreateOrigin(TestStations.Surbiton, TestSchedules.Ten),
                TestScheduleLocations.CreateSetdownOnlyStop(TestStations.ClaphamJunction, TenFifteen),
                TestScheduleLocations.CreateDestination(TestStations.Waterloo, TestSchedules.TenThirty)
            };

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

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

            var arrivals = stop.GetArrivalTimes();
            var service  = arrivals.GetService(TenFifteen);

            Assert.Equal(testSchedule.Service, service);

            AssertNoDepartureTime(stop, TenFifteen);
        }
コード例 #28
0
        public void SetdownStopHasIsNotPublicDeparture()
        {
            IDeparture departure = TestScheduleLocations.CreateSetdownOnlyStop(TestStations.Surbiton, TestSchedules.Ten);

            Assert.False(departure.IsPublic);
        }
コード例 #29
0
        public void PickupOnlyStopIsPublicDeparture()
        {
            IDeparture departure = TestScheduleLocations.CreatePickupOnlyStop(TestStations.Surbiton, TestSchedules.Ten);

            Assert.True(departure.IsPublic);
        }
コード例 #30
0
        public void OriginStopHasPublicDeparture()
        {
            IDeparture departure = TestScheduleLocations.CreateOrigin(TestStations.Surbiton, TestSchedules.Ten);

            Assert.True(departure.IsPublic);
        }