Ejemplo n.º 1
0
        public void TestResyncEvents()
        {
            LMProject     p = CreateProject(false);
            int           offset1 = 100, offset2 = 120, offset3 = 150;
            Period        period;
            List <Period> syncedPeriods;

            period = new Period();
            period.Nodes.Add(new TimeNode {
                Start = new Time(0),
                Stop  = new Time(3000)
            });
            p.Periods.Add(period);
            period = new Period();
            period.Nodes.Add(new TimeNode {
                Start = new Time(3001),
                Stop  = new Time(6000)
            });
            p.Periods.Add(period);
            period = new Period();
            period.Nodes.Add(new TimeNode {
                Start = new Time(6001),
                Stop  = new Time(6500)
            });
            p.Periods.Add(period);

            /* Test with a list of periods that don't match */
            Assert.Throws <IndexOutOfRangeException> (
                delegate {
                p.ResyncEvents(new List <Period> ());
            });

            syncedPeriods = new List <Period> ();
            period        = new Period();
            period.Nodes.Add(new TimeNode {
                Start = new Time(0 + offset1),
                Stop  = new Time(3000 + offset1)
            });
            syncedPeriods.Add(period);
            period = new Period();
            period.Nodes.Add(new TimeNode {
                Start = new Time(3001 + offset2),
                Stop  = new Time(6000 + offset2)
            });
            syncedPeriods.Add(period);
            period = new Period();
            period.Nodes.Add(new TimeNode {
                Start = new Time(6001 + offset3),
                Stop  = new Time(6500 + offset3)
            });
            syncedPeriods.Add(period);

            /* 1st Period */
            p.Timeline.Add(new LMTimelineEvent {
                EventTime = new Time(0)
            });
            p.Timeline.Add(new LMTimelineEvent {
                EventTime = new Time(1500)
            });
            p.Timeline.Add(new LMTimelineEvent {
                EventTime = new Time(3000)
            });
            /* 2nd Period */
            p.Timeline.Add(new LMTimelineEvent {
                EventTime = new Time(3001)
            });
            p.Timeline.Add(new LMTimelineEvent {
                EventTime = new Time(4500)
            });
            p.Timeline.Add(new LMTimelineEvent {
                EventTime = new Time(6000)
            });
            /* 3nd Period */
            p.Timeline.Add(new LMTimelineEvent {
                EventTime = new Time(6001)
            });
            p.Timeline.Add(new LMTimelineEvent {
                EventTime = new Time(6200)
            });
            p.Timeline.Add(new LMTimelineEvent {
                EventTime = new Time(6500)
            });

            IList <TimelineEvent> oldTimeline = p.Timeline.Clone();

            p.ResyncEvents(syncedPeriods);
            Assert.AreEqual(oldTimeline [0].EventTime + offset1, p.Timeline [0].EventTime);
            Assert.AreEqual(oldTimeline [1].EventTime + offset1, p.Timeline [1].EventTime);
            Assert.AreEqual(oldTimeline [2].EventTime + offset1, p.Timeline [2].EventTime);

            Assert.AreEqual(oldTimeline [3].EventTime + offset2, p.Timeline [3].EventTime);
            Assert.AreEqual(oldTimeline [4].EventTime + offset2, p.Timeline [4].EventTime);
            Assert.AreEqual(oldTimeline [5].EventTime + offset2, p.Timeline [5].EventTime);

            Assert.AreEqual(oldTimeline [6].EventTime + offset3, p.Timeline [6].EventTime);
            Assert.AreEqual(oldTimeline [7].EventTime + offset3, p.Timeline [7].EventTime);
            Assert.AreEqual(oldTimeline [8].EventTime + offset3, p.Timeline [8].EventTime);
        }