void TestTimerCompletedOnCorrectPhase(SequenceTimer timer)
        {
            // SequenceTimer timer = (SequenceTimer)sender;
            Phase phase = timer.Start as Phase;

            Assert.AreEqual(timer.IsTracking, false);

            Assert.AreEqual(6, Sequence.ActiveSegment.Number);
        }
        public void TrackingDurationWithOneOrMorePhase_TimerActivatesAtBeginningOfAppropriatePhase()
        {
            Time = 3;
            SequenceTimer timer = new SequenceTimer(DurationUnit.Phase, Time, Sequence);

            timer.TimerAction += new SequenceTimerAction(TestTimerCompletedOnCorrectPhase);
            timer.StartTimer();

            Sequence.CompleteActivePhase();
            Sequence.CompleteActivePhase();
            Sequence.CompleteActivePhase();
        }
        public void TrackingDurationWithOneOrMoreTurns_TimerActivatesAtppropriateTurn()
        {
            //get past segment 12
            Time = 3;
            SequenceTimer timer = new SequenceTimer(DurationUnit.Turn, Time, Sequence);

            timer.TimerAction += new SequenceTimerAction(TestTimerCompletedAtEndOfTurn);
            timer.StartTimer();
            Sequence.CompleteActivePhase();
            Sequence.CompleteActivePhase();
            Sequence.CompleteActivePhase();
            Sequence.CompleteActivePhase();
            Sequence.CompleteActivePhase();
            Sequence.CompleteActivePhase();

            Assert.IsNotNull(timer.Stop);
            Assert.AreEqual(timer.Stop, Sequence.Segments[12]);
        }
        void TestTimerCompletedOnCorrectSegment(SequenceTimer timer)
        {
            // SequenceTimer timer = (SequenceTimer)sender;
            Segment seg = timer.Start as Segment;

            int dest = 0;

            if (seg.Number + timer.Time <= 12)
            {
                dest = seg.Number + timer.Time;
            }
            else
            {
                dest = seg.Number + timer.Time - 12;
            }

            Assert.AreEqual(dest, Sequence.ActiveSegment.Number);
        }
        public void TrackingDurationWithOneOrMoreSegmentsToEndOfSegment_TimerActivatesAtEndOfAppropriateSegment()
        {
            Time = 2;
            SequenceTimer timer = new SequenceTimer(DurationUnit.Segment, Time, Sequence, Timing.End);

            timer.TimerAction += new SequenceTimerAction(TestTimerCompletedOnCorrectSegment);
            timer.StartTimer();

            //complete phase 12
            Sequence.CompleteActivePhase();
            Assert.IsNull(timer.Stop);

            //complete phase 2
            Sequence.CompleteActivePhase();

            //timer stops after phase 2
            Segment segment = (Segment)timer.Stop;

            Assert.AreEqual(2, segment.Number);
        }
        public void TrackingDurationWithOneOrMorePhasesToEndOfPhase_TimerActivatesAtEndOfAppropriatePhase()
        {
            Time = 3;
            SequenceTimer timer = new SequenceTimer(DurationUnit.Phase, Time, Sequence, Timing.End);

            timer.TimerAction += new SequenceTimerAction(TestTimerCompletedOnCorrectPhase);
            timer.StartTimer();

            //go to phase 6
            Sequence.CompleteActivePhase();
            Sequence.CompleteActivePhase();
            Sequence.CompleteActivePhase();

            Assert.IsNull(timer.Stop);
            Phase phase2 = Character.ActivePhase;

            //complete phase 6 - timer shoukd run
            Sequence.CompleteActivePhase();
            Assert.IsNotNull(timer.Stop);
            Assert.AreEqual(timer.Stop, phase2);
        }
        public void TrackingDurationWithOneOrMoreSegment_TimerActivatesAtBeginningOfAppropriateSegment()
        {
            Time = 1;
            SequenceTimer timer = new SequenceTimer(DurationUnit.Segment, Time, Sequence);

            timer.TimerAction += new SequenceTimerAction(TestTimerCompletedOnCorrectSegment);
            timer.StartTimer();

            var x = Sequence.ActivateNextSegment;


            Time       = 4;
            timer.Time = Time;


            timer.TimerAction += new SequenceTimerAction(TestTimerCompletedOnCorrectSegment);
            timer.StartTimer();
            x = Sequence.ActivateNextSegment;
            x = Sequence.ActivateNextSegment;
            x = Sequence.ActivateNextSegment;
            x = Sequence.ActivateNextSegment;
        }
        public void TrackingTimingWithRepeatingEvents_TimerActivatesNumberOfTimes()
        {
            Time = 1;
            int           Repeat = 3;
            SequenceTimer timer  = new SequenceTimer(DurationUnit.Segment, Time, Sequence, Timing.Start, 0);

            timer.TimerAction += new SequenceTimerAction(TestTimerCompletedOnCorrectSegment);
            timer.StartTimer();

            var x = Sequence.ActivateNextSegment;


            Time       = 4;
            timer.Time = Time;


            timer.TimerAction += new SequenceTimerAction(TestTimerCompletedOnCorrectSegment);
            timer.StartTimer();
            x = Sequence.ActivateNextSegment;
            x = Sequence.ActivateNextSegment;
            x = Sequence.ActivateNextSegment;
            x = Sequence.ActivateNextSegment;
        }
 void TestTimerCompletedAtEndOfTurn(SequenceTimer sender)
 {
 }