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);
        }
        public void LocationHasMultipleServicesForWhenOnSameTime()
        {
            var surbiton = TestStations.Surbiton;
            var waterloo = TestStations.Waterloo;

            var locations1 = new[]
            {
                (ScheduleLocation)TestScheduleLocations.CreateOrigin(surbiton, TestSchedules.Ten),
                TestScheduleLocations.CreateDestination(waterloo, TestSchedules.TenThirty)
            };
            var service1 = TestSchedules.CreateScheduleWithService(timetableId: "A00001", stops: locations1);

            var locations2 = new[]
            {
                (ScheduleLocation)TestScheduleLocations.CreateOrigin(surbiton, TestSchedules.Ten),
                TestScheduleLocations.CreateDestination(waterloo, TestSchedules.TenThirty)
            };
            var service2 = TestSchedules.CreateScheduleWithService(timetableId: "A00002", stops: locations2);

            var destination = service1.Locations.Last().Station.Timetable;

            var arrivals = destination.GetArrivalTimes();
            var services = arrivals.GetServices(TestSchedules.TenThirty);

            Assert.Equal(2, services.Length);
        }
Exemple #3
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));
        }
        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);
        }
        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);
        }
        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);
        }
Exemple #7
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);
        }
Exemple #8
0
        public void MapScheduleOrigin()
        {
            var mapper = ToViewProfileConfiguration.CreateMapper();

            var input = TestScheduleLocations.CreateOrigin(
                TestLocations.Surbiton,
                new Time(TestTime.Ten));

            var output = Map(input);

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

            Assert.Equal(expected, output.Departure);
            Assert.Equal("1", output.Platform);
            Assert.Equal("TB", output.Activities);
            Assert.Null(output.PassesAt);
            Assert.Null(output.Arrival);
        }
        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);
        }
Exemple #10
0
        public void ComesFromWorksWithJoinsWhereMainStartsAtJoinPoint()
        {
            //  Starts at Clapham
            var mainStops = CreateMainStops();

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

            var at    = new StopSpecification(TestStations.Waterloo, TestSchedules.TenThirty, 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);
        }
        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);
        }
        public void OriginStopHasPublicDeparture()
        {
            IDeparture departure = TestScheduleLocations.CreateOrigin(TestStations.Surbiton, TestSchedules.Ten);

            Assert.True(departure.IsPublic);
        }
        public void ScheduleOriginStopTypeIsOrigin()
        {
            var scheduleLocation = TestScheduleLocations.CreateOrigin(TestStations.Surbiton, Test);

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