Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public void SetsAssociationStopWhenConstructed()
        {
            var main        = TestSchedules.CreateService();
            var association = TestSchedules.CreateAssociation(main, "X98765");

            Assert.Null(association.Stop);

            var withAssociation = new ResolvedServiceWithAssociations(main, new [] { association });

            Assert.NotNull(association.Stop);
        }
Exemplo n.º 3
0
        public static ResolvedServiceWithAssociations CreateServiceWithAssociation(
            ResolvedService resolved,
            bool associationIsCancelled = false,
            string associatedUid        = "A98765",
            bool isNextDay = false)
        {
            var association = CreateAssociation(resolved, associatedUid, associationIsCancelled, isNextDay);
            var resolvedWithAssociations = new ResolvedServiceWithAssociations(resolved, new [] { association });

            return(resolvedWithAssociations);
        }
Exemplo n.º 4
0
        public void AllAssociationsAreCancelled()
        {
            var main         = TestSchedules.CreateService();
            var association1 = TestSchedules.CreateAssociation(main, "X98765", true);
            var association2 = TestSchedules.CreateAssociation(main, "X56789", true);

            var withAssociation = new ResolvedServiceWithAssociations(main, new [] { association1, association2 });

            withAssociation.RemoveCancelledAssociations();

            Assert.False(withAssociation.HasAssociations());
            Assert.Empty(withAssociation.Associations);
        }
Exemplo n.º 5
0
        public void RemoveCancelledAssociation()
        {
            var main         = TestSchedules.CreateService();
            var association1 = TestSchedules.CreateAssociation(main, "X98765", true);
            var association2 = TestSchedules.CreateAssociation(main, "X56789");

            var withAssociation = new ResolvedServiceWithAssociations(main, new [] { association1, association2 });

            withAssociation.RemoveCancelledAssociations();

            Assert.Single(withAssociation.Associations);
            Assert.Equal(association2, withAssociation.Associations[0]);
        }
Exemplo n.º 6
0
        public void RemoveAssociationWithCancelledService()
        {
            var main         = TestSchedules.CreateService();
            var associated   = TestSchedules.CreateService("X98765", stops: TestSchedules.CreateWokingClaphamSchedule(TestSchedules.NineForty), isCancelled: true);
            var association1 = TestSchedules.CreateAssociation(main, associated);
            var association2 = TestSchedules.CreateAssociation(main, "X56789");

            var withAssociation = new ResolvedServiceWithAssociations(main, new [] { association1, association2 });

            withAssociation.RemoveCancelledAssociations();

            Assert.Single(withAssociation.Associations);
            Assert.Equal(association2, withAssociation.Associations[0]);
        }
Exemplo n.º 7
0
        public void SetsAssociationWhenMultipleAssociations()
        {
            var main         = TestSchedules.CreateService();
            var association1 = TestSchedules.CreateAssociation(main, "X98765");
            var association2 = TestSchedules.CreateAssociation(main, "X56789");

            Assert.Null(association1.Stop);
            Assert.Null(association2.Stop);

            var withAssociation = new ResolvedServiceWithAssociations(main, new [] { association1, association2 });

            Assert.NotNull(association1.Stop);
            Assert.NotNull(association2.Stop);
        }
Exemplo n.º 8
0
        public void RemoveBrokenWhenCancelledAssociation()
        {
            var main            = TestSchedules.CreateService();
            var association1    = TestSchedules.CreateAssociation(main, "X98765", true);
            var association2    = TestSchedules.CreateAssociation(main, "X56789");
            var withAssociation = new ResolvedServiceWithAssociations(main, new [] { association1, association2 });

            association2.AsDynamic().Stop = new ResolvedAssociationStop(association2.Stop.Stop, null);

            withAssociation.RemoveBrokenAssociations();

            Assert.Single(withAssociation.Associations);
            Assert.Equal(association1, withAssociation.Associations[0]);
        }
Exemplo n.º 9
0
        public void HasAssociations(ResolvedAssociation[] associations, bool expected)
        {
            var resolved = new ResolvedServiceWithAssociations(TestSchedules.CreateService(), associations);

            Assert.Equal(expected, resolved.HasAssociations());
        }