Exemple #1
0
        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);
        }