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); }
public void IsStopAtAlwaysFalseForPassingPoint(TimesToUse arrivalOrDeparture) { var stop = TestScheduleLocations.CreatePass(Surbiton, TestSchedules.Ten); var spec = CreateFindSpec(TestSchedules.Ten, arrivalOrDeparture); Assert.False(stop.IsStopAt(spec)); }
private ScheduleStop CreateScheduleStop() { var stop = TestScheduleLocations.CreateStop(TestStations.Surbiton, TestSchedules.Ten); TestSchedules.CreateScheduleWithService(stops: new ScheduleLocation[] { stop }); return(stop); }
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)); }
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); }
private ScheduleLocation[] CreateMainStops(Time departs) { var mainStops = TestSchedules.CreateFourStopSchedule(departs); mainStops[3] = TestScheduleLocations.CreateStop(TestStations.Vauxhall, TestSchedules.TenTwenty); // Make Vauxhall a stop return(mainStops); }
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)); }
private ScheduleLocation[] CreateMainStops() { var mainStops = TestSchedules.CreateThreeStopSchedule(TestSchedules.Ten); mainStops[2] = TestScheduleLocations.CreateStop(TestStations.Vauxhall, TestSchedules.TenTwenty); // Make Vauxhall a stop return(mainStops); }
public void AddDayToSchedulePass() { var scheduleLocation = TestScheduleLocations.CreatePass(TestStations.Surbiton, Test); scheduleLocation.AddDay(Start); Assert.Equal(Expected, scheduleLocation.PassesAt); }
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); }
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 AddDayToScheduleDestination() { var scheduleLocation = TestScheduleLocations.CreateDestination(TestStations.Surbiton, Test); scheduleLocation.AddDay(Start); Assert.Equal(Expected, scheduleLocation.Arrival); Assert.Equal(Expected.Subtract(ThirtySeconds), scheduleLocation.WorkingArrival); }
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)); }
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)); }
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); }
public void ReturnNullWhenInvalidTime() { var mapper = ToViewProfileConfiguration.CreateMapper(); var input = TestScheduleLocations.CreateStop( TestLocations.Surbiton, Time.NotValid); var output = Map(input); Assert.Null(output.Arrival); }
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); }
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); }
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); }
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); }
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); }
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); }
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 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); }
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 SetdownStopHasIsNotPublicDeparture() { IDeparture departure = TestScheduleLocations.CreateSetdownOnlyStop(TestStations.Surbiton, TestSchedules.Ten); Assert.False(departure.IsPublic); }
public void PickupOnlyStopIsPublicDeparture() { IDeparture departure = TestScheduleLocations.CreatePickupOnlyStop(TestStations.Surbiton, TestSchedules.Ten); Assert.True(departure.IsPublic); }
public void OriginStopHasPublicDeparture() { IDeparture departure = TestScheduleLocations.CreateOrigin(TestStations.Surbiton, TestSchedules.Ten); Assert.True(departure.IsPublic); }