public void MapAssociationWhereAssociatedServiceDoesNotHaveLocation(bool isCancelled) { var mapper = ToViewProfileConfiguration.CreateMapper(); var resolved = TestSchedules.CreateServiceWithAssociation(@on: TestDate, isCancelled, "X12345", "A98765", false); var association = resolved.Associations[0]; var newStops = TestSchedules.CreateWokingClaphamSchedule(TestSchedules.NineForty) .Where(l => !l.Station.Equals(TestStations.ClaphamJunction)) .ToArray(); var newService = TestSchedules.CreateScheduleWithService("A98765", stops: newStops); var newAssociation = new ResolvedAssociation( association.Details, association.On, association.IsCancelled, new ResolvedService(newService, association.On, false)); resolved = new ResolvedServiceWithAssociations(resolved, new [] { newAssociation }); var output = mapper.Map <Timetable.ResolvedService, Model.Service>(resolved, opts => opts.Items["On"] = resolved.On); Assert.True(output.Associations[0].IsBroken); Assert.Null(output.Associations[0].AssociatedServiceStop); Assert.Equal(isCancelled, output.Associations[0].IsCancelled); }
public void IsMain(string timetableId, bool expected) { var association = new ResolvedAssociation( TestAssociations.CreateAssociation(), DateTime.Today, false, null); ; Assert.Equal(expected, association.IsMain(timetableId)); }
public void IsSplit(AssociationCategory category, bool expected) { var association = TestAssociations.CreateAssociationWithServices(category: category); var resolved = new ResolvedAssociation( association, DateTime.Today, false, null); ; Assert.Equal(expected, resolved.IsSplit); }
public void GetStopNotFoundReturnsNull() { var association = TestAssociations.CreateAssociationWithServices(location: TestLocations.Weybridge); association.Main.Service.TryResolveOn(Aug10, out var resolvedService); var resolved = new ResolvedAssociation( association, DateTime.Today, false, null); var stop = resolved.GetStop(resolvedService); Assert.Null(stop); }
public void GetStopOnMain() { var association = TestAssociations.CreateAssociationWithServices(); association.Main.Service.TryResolveOn(Aug10, out var resolvedService); var resolved = new ResolvedAssociation( association, DateTime.Today, false, null); var stop = resolved.GetStop(resolvedService); Assert.NotNull(stop); Assert.Equal(TestLocations.CLPHMJN, stop.Stop.Stop.Location); Assert.Equal("X12345", stop.Service.TimetableUid); }
public void SetAssociationStop() { var association = TestAssociations.CreateAssociationWithServices(); association.Main.Service.TryResolveOn(Aug10, out var resolvedService); association.Associated.Service.TryResolveOn(Aug10, out var resolvedAssociatedService); var resolved = new ResolvedAssociation( association, DateTime.Today, false, resolvedAssociatedService); ; resolved.SetAssociationStop(resolvedService); var stop = resolved.Stop; Assert.NotNull(stop); Assert.Equal(TestLocations.CLPHMJN, stop.Stop.Stop.Location); Assert.Equal(TestLocations.CLPHMJN, stop.AssociatedServiceStop.Stop.Location); }
private A MapAssociation(ResolvedAssociation source, ResolvedService service, ResolutionContext context) { var(associatedService, associatedServiceStop) = MapOtherService(); var association = new A() { Stop = MapStop(source.Stop.Stop, context), IsBroken = source.Stop.IsBroken, IsCancelled = source.IsCancelled, IsMain = source.IsMain(service.TimetableUid), Date = source.On, AssociationCategory = source.Details.Category.ToString(), AssociatedServiceStop = associatedServiceStop }; SetAssociatedService(association, associatedService); return(association); (S, Model.ScheduledStop) MapOtherService() { // Association maybe on different day. var originalDate = context.Items["On"]; try { var otherService = CreateService(source.AssociatedService, context); var otherStop = MapStop(source.Stop.AssociatedServiceStop, context); return(otherService, otherStop); } finally { // Reset service date context.Items["On"] = originalDate; } } }