Esempio n. 1
0
        public static ILocationData CreateTimetabledLocations(int duration = 1440, bool cancelTimetable = false)
        {
            var data     = Locations;
            var surbiton = data.LocationsByTiploc["SURBITN"];
            var waterloo = data.LocationsByTiploc["WATRLMN"];
            var clapham  = data.LocationsByTiploc["CLPHMJN"];


            for (int i = 0; i < duration; i += 15)
            {
                var start = First.AddMinutes(i);
                var stops = new[]
                {
                    (ScheduleLocation)TestScheduleLocations.CreateOrigin(surbiton, start),
                    TestScheduleLocations.CreateStop(clapham, start.AddMinutes(5)),
                    TestScheduleLocations.CreateDestination(waterloo, start.AddMinutes(10))
                };

                var uid          = $"X{i:D5}";
                var testSchedule = TestSchedules.CreateScheduleWithService(timetableId: uid, stops: stops);
                if (cancelTimetable)
                {
                    var cancelledSchedule =
                        TestSchedules.CreateScheduleWithService(uid, StpIndicator.Cancelled, service: testSchedule.Service);
                }
            }

            return(data);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
        public static Association CreateAssociationWithServices(
            CifService mainService                 = null,
            CifService associatedService           = null,
            StpIndicator indicator                 = StpIndicator.Permanent,
            ICalendar calendar                     = null,
            Location location                      = null,
            AssociationCategory category           = AssociationCategory.Join,
            AssociationDateIndicator dateIndicator = AssociationDateIndicator.Standard,
            string associatedUid                   = "A98765",
            string retailServiceId                 = "VT123402"
            )
        {
            mainService       = mainService ?? TestSchedules.CreateScheduleWithService("X12345").Service;
            associatedService = associatedService ?? TestSchedules.CreateScheduleWithService(associatedUid, retailServiceId: retailServiceId).Service;

            var association = CreateAssociation(mainService.TimetableUid, associatedService.TimetableUid, indicator, calendar, location, category,
                                                dateIndicator);

            mainService.AddAssociation(association, true);
            associatedService.AddAssociation(association, false);

            return(association);
        }