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); }
private static Model.Service MapResolvedService( bool isCancelled = false, string mainUid = "X12345", string associatedUid = "A98765", bool isNextDay = false) { var mapper = ToViewProfileConfiguration.CreateMapper(); var resolved = TestSchedules.CreateServiceWithAssociation(on: TestDate, isCancelled, mainUid, associatedUid, isNextDay); var service = mapper.Map <Timetable.ResolvedService, Model.Service>(resolved, opts => opts.Items["On"] = resolved.On); return(service); }
public void MapAssociationWhereMainServiceDoesNotHaveLocation(bool isCancelled) { var mapper = ToViewProfileConfiguration.CreateMapper(); var newStops = TestSchedules.DefaultLocations .Where(l => !l.Station.Equals(TestStations.ClaphamJunction)) .ToArray(); var mainService = TestSchedules.CreateService(stops: newStops); var resolved = TestSchedules.CreateServiceWithAssociation(mainService, isCancelled); 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].Stop); Assert.Equal(isCancelled, output.Associations[0].IsCancelled); }