Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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]);
        }
Пример #4
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]);
        }
Пример #5
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);
        }
Пример #6
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]);
        }