public void AddSameAssociationWithDifferentLocationsResolveToCorrectForAssociated(string activities, AssociationCategory joinSplit, bool expectedHasAssociation) { Test(TestLocations.CLPHMJN, TestLocations.Woking); Test(TestLocations.Woking, TestLocations.CLPHMJN); void Test(Location location1, Location location2) { var stops = CreateAssociateStopsSettingClaphamActivities(joinSplit, activities); var service = TestSchedules.CreateScheduleWithService("A12345", stops: stops).Service; var association1 = TestAssociations.CreateAssociation(mainUid: "A67890", associatedUid: "A12345", category: joinSplit, location: location1); var association2 = TestAssociations.CreateAssociation(mainUid: "A67890", associatedUid: "A12345", category: joinSplit, location: location2); service.AddAssociation(association1, false); service.AddAssociation(association2, false); Assert.Equal(expectedHasAssociation, service.HasAssociations()); if (expectedHasAssociation) { var associations = service.GetAssociations()["A67890"]; Assert.Single(associations); Assert.Equal(TestLocations.CLPHMJN, associations.Single().Value.AtLocation); } } }
private static Model.FoundSummaryItem MapResolvedStop(Timetable.CifSchedule schedule = null, Timetable.Station at = null, Time?time = null, Timetable.Station from = null, Timetable.Station to = null) { schedule = schedule ?? TestSchedules.CreateScheduleWithService(); at = at ?? TestStations.Surbiton; time = time ?? TestSchedules.Ten; var find = new StopSpecification(at, time.Value, TestDate, TimesToUse.Departures); var resolved = new ResolvedService(schedule, TestDate, false); resolved.TryFindStop(find, out var stop); if (to != null) { stop.GoesTo(to); } if (from != null) { stop.ComesFrom(from); } var mapper = ToViewProfileConfiguration.CreateMapper(); return(mapper.Map <Timetable.ResolvedServiceStop, Model.FoundSummaryItem>(stop, opts => opts.Items["On"] = stop.On)); }
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); }
public void NotConsistentLocationWhenCannotFindTheStop(bool isMain) { var association = TestAssociations.CreateAssociation(location: TestLocations.Weybridge); var schedule = TestSchedules.CreateScheduleWithService(); Assert.False(association.HasConsistentLocation(schedule, isMain)); }
private ScheduleStop CreateScheduleStop() { var stop = TestScheduleLocations.CreateStop(TestStations.Surbiton, TestSchedules.Ten); TestSchedules.CreateScheduleWithService(stops: new ScheduleLocation[] { stop }); return(stop); }
public void AddToServiceThrowsExceptionWhenNotMatchingId(bool isMain) { var schedule = TestSchedules.CreateScheduleWithService("Q11111"); var association = TestAssociations.CreateAssociation(); var ex = Assert.Throws <ArgumentException>(() => association.SetService(schedule.Service, isMain)); }
public void AddToServiceThrowsExceptionWhenNotMatchingId(string uid, bool success) { var schedule = TestSchedules.CreateScheduleWithService(uid); var associationService = TestAssociations.CreateAssociation().Main; Assert.Equal(success, associationService.TrySetService(schedule.Service)); }
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 TryGetScheduleSingleSchedule() { var baseSchedule = TestSchedules.CreateScheduleWithService(); var service = baseSchedule.Service; Assert.True(service.TryGetSchedule((StpIndicator.Permanent, TestSchedules.EverydayAugust2019), out var schedule)); Assert.Equal(baseSchedule, schedule); }
public void TryFindScheduleReturnsFalseWhenNoSchedulesRunOnDate() { var schedule = TestSchedules.CreateScheduleWithService(calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Wednesday)); var service = schedule.Service; Assert.False(service.TryResolveOn(MondayAugust12, out var found)); Assert.Null(found); }
public void HasConsistentLocationOnAssociated(string activities, AssociationCategory joinSplit, bool expected) { var stops = AssociationDictionaryTest.CreateAssociateStopsSettingClaphamActivities(joinSplit, activities); var schedule = TestSchedules.CreateScheduleWithService(stops: stops); var association = TestAssociations.CreateAssociation(category: joinSplit); Assert.Equal(expected, association.HasConsistentLocation(schedule, false)); }
public void NoAssociationsReturnsResolvedService() { var schedule = TestSchedules.CreateScheduleWithService(); var service = schedule.Service; service.TryResolveOn(MondayAugust12, out var found); Assert.IsType <ResolvedService>(found); }
public void TryFindScheduleOnRunningOnDate() { var schedule = TestSchedules.CreateScheduleWithService(calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Wednesday)); var service = schedule.Service; Assert.True(service.TryResolveOn(MondayAugust12.AddDays(2), out var found)); Assert.Equal(schedule, found.Details); }
public void TryFindScheduleStopOnRunningOnDate() { var schedule = TestSchedules.CreateScheduleWithService(calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Wednesday)); var service = schedule.Service; var find = CreateFindSpec(TestSchedules.TenSixteen, MondayAugust12.AddDays(2)); Assert.True(service.TryFindScheduledStop(find, out var found)); Assert.Equal(schedule, found.Service.Details); }
public void ServiceIsStopsService() { var schedule = TestSchedules.CreateScheduleWithService(calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Wednesday)); var service = schedule.Service; var serviceTime = new DepartureServiceTime(schedule.Locations.First() as IDeparture); Assert.Equal(service, serviceTime.Service); }
public void TryFindScheduleStopReturnsFalseWhenNoStopAtTime() { var schedule = TestSchedules.CreateScheduleWithService(calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Wednesday)); var service = schedule.Service; var find = CreateFindSpec(TestSchedules.Ten, MondayAugust12.AddDays(2)); Assert.False(service.TryFindScheduledStop(find, out var found)); Assert.Null(found); }
private Association CreateJoinServices() { var main = TestSchedules.CreateScheduleWithService("X12345", retailServiceId: "VT123401").Service; var associated = TestSchedules.CreateScheduleWithService("A98765", retailServiceId: "VT123402", stops: TestSchedules.CreateWokingClaphamSchedule(TestSchedules.NineForty)).Service; var association = TestAssociations.CreateAssociationWithServices(main, associated); return(association); }
public void NullReturnedIfNoSchedulesRunOnDate() { var schedule = TestSchedules.CreateScheduleWithService(calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Wednesday)); var service = schedule.Service; var schedule2 = TestSchedules.CreateSchedule(calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Thursday), service: service); service.TryResolveOn(MondayAugust12, out var found); Assert.Null(found); }
public void AddToServiceAddAssociatedService() { var schedule = TestSchedules.CreateScheduleWithService("A98765"); var association = TestAssociations.CreateAssociation(); association.SetService(schedule.Service, false); Assert.Equal(schedule.Service, association.Associated.Service); Assert.Null(association.Main.Service); }
public void AssociationsReturnsResolvedServiceWithAssociations() { var schedule = TestSchedules.CreateScheduleWithService(); var service = schedule.Service; var association = TestAssociations.CreateAssociationWithServices(mainService: service); service.TryResolveOn(MondayAugust12, out var found); Assert.IsType <ResolvedServiceWithAssociations>(found); }
public void FailToAddAssociation() { var service = TestSchedules.CreateScheduleWithService().Service; var association = TestAssociations.CreateAssociation(); service.AddAssociation(association, true); // Adding same association can result in failing to add Assert.False(service.AddAssociation(association, true)); Assert.False(service.HasAssociations()); }
private static Model.ServiceSummary MapSchedule(Timetable.CifSchedule schedule = null, bool isCancelled = false) { var mapper = ToViewProfileConfiguration.CreateMapper(); schedule = schedule ?? TestSchedules.CreateScheduleWithService(); var resolved = new ResolvedService(schedule, TestDate, isCancelled); return(mapper.Map <Timetable.ResolvedService, Model.ServiceSummary>(resolved, opts => opts.Items["On"] = resolved.On)); }
private Association CreateJoinServices(ScheduleLocation[] mainStops = null) { mainStops = mainStops ?? TestSchedules.CreateThreeStopSchedule(TestSchedules.Ten); var main = TestSchedules.CreateScheduleWithService("X12345", retailServiceId: "VT123401", stops: mainStops).Service; var associated = TestSchedules.CreateScheduleWithService("A98765", retailServiceId: "VT123402", stops: TestSchedules.CreateWokingClaphamSchedule(TestSchedules.NineForty)).Service; var association = TestAssociations.CreateAssociationWithServices(main, associated); return(association); }
private Association CreateJoinServices(Time associationDeparts, ScheduleLocation[] mainStops = null) { mainStops ??= CreateMainStops(); var main = TestSchedules.CreateScheduleWithService("X12345", retailServiceId: "VT123401", stops: mainStops).Service; var associated = TestSchedules.CreateScheduleWithService("A98765", retailServiceId: "VT123402", stops: TestSchedules.CreateWokingClaphamSchedule(associationDeparts)).Service; var association = TestAssociations.CreateAssociationWithServices(main, associated); return(association); }
private Association CreateSplitServices(ScheduleLocation[] mainStops = null) { mainStops ??= CreateMainStops(); var main = TestSchedules.CreateScheduleWithService("X12345", retailServiceId: "VT123401", stops: mainStops).Service; var associated = TestSchedules.CreateScheduleWithService("A98765", retailServiceId: "VT123402", stops: TestSchedules.CreateClaphamWokingSchedule(TestSchedules.TenTwentyFive)).Service; var association = TestAssociations.CreateAssociationWithServices(main, associated, category: AssociationCategory.Split); return(association); }
public void CancelledScheduleReturned(StpIndicator lowIndicator) { var baseSchedule = TestSchedules.CreateScheduleWithService(indicator: lowIndicator, calendar: TestSchedules.EverydayAugust2019); var service = baseSchedule.Service; TestSchedules.CreateSchedule(indicator: StpIndicator.Cancelled, calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Monday), service: service); service.TryResolveOn(MondayAugust12, out var found); Assert.True(found.IsCancelled); Assert.Equal(baseSchedule, found.Details); }
public void HighIndicatorsTakePriorityOverLow(StpIndicator lowIndicator, StpIndicator highIndicator) { var low = TestSchedules.CreateScheduleWithService(indicator: lowIndicator, calendar: TestSchedules.EverydayAugust2019); var service = low.Service; var high = TestSchedules.CreateSchedule(indicator: highIndicator, calendar: TestSchedules.EverydayAugust2019, service: service); TestSchedules.CreateSchedule(indicator: lowIndicator, calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Monday), service: service); service.TryResolveOn(MondayAugust12, out var found); Assert.Equal(high, found.Details); }
public void WhenIsAssociatedAddMainUid() { var service = TestSchedules.CreateScheduleWithService("A98765").Service; var association = TestAssociations.CreateAssociation(); Assert.True(service.AddAssociation(association, false)); Assert.True(service.HasAssociations()); var associations = service.GetAssociations(); Assert.NotEmpty(associations["X12345"]); }
public void WhenIsMainAddsAssociatedUid() { var service = TestSchedules.CreateScheduleWithService().Service; var association = TestAssociations.CreateAssociation(); Assert.True(service.AddAssociation(association, true)); Assert.True(service.HasAssociations()); var associations = service.GetAssociations(); Assert.NotEmpty(associations["A98765"]); }
public void LocationHasOnlyOneEntryForMultipleSchedules() { var permanent = TestSchedules.CreateScheduleWithService(); var overlay = TestSchedules.CreateSchedule(indicator: StpIndicator.Override, service: permanent.Service); var destination = permanent.Locations.Last().Station.Timetable; var arrivals = destination.GetArrivalTimes(); var services = arrivals.GetServices(TestSchedules.TenThirty); Assert.Single(services); }