Inheritance: ITimePeriodChain
        public void AddTimeRangeTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodChain timePeriods = new TimePeriodChain( schoolDay );

            TimeRange timeRange = new TimeRange( schoolDay.Lesson1.Start, schoolDay.Lesson1.End );

            timePeriods.Add( timeRange );
            Assert.AreEqual( timePeriods.Last, timeRange );
        }
        public void ClearTest()
        {
            TimePeriodChain timePeriods = new TimePeriodChain();
            Assert.AreEqual( timePeriods.Count, 0 );
            timePeriods.Clear();
            Assert.AreEqual( timePeriods.Count, 0 );

            SchoolDay schoolDay = new SchoolDay();
            Assert.AreEqual( schoolDay.Count, 7 );
            schoolDay.Clear();
            Assert.AreEqual( schoolDay.Count, 0 );
        }
        public void StartTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            TimePeriodChain timePeriods = new TimePeriodChain();
            Assert.AreEqual( timePeriods.Start, TimeSpec.MinPeriodDate );

            timePeriods.Add( new TimeBlock( now, Duration.Hour ) );
            Assert.AreEqual( timePeriods.Start, now );

            timePeriods.Clear();
            Assert.AreEqual( timePeriods.Start, TimeSpec.MinPeriodDate );
        }
        public void IsMomentTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            TimePeriodChain timePeriods = new TimePeriodChain();
            Assert.IsFalse( timePeriods.IsMoment );

            timePeriods.Add( new TimeBlock( now ) );
            Assert.AreEqual( timePeriods.Count, 1 );
            Assert.IsTrue( timePeriods.HasStart );
            Assert.IsTrue( timePeriods.HasEnd );
            Assert.IsTrue( timePeriods.IsMoment );

            timePeriods.Add( new TimeBlock( now ) );
            Assert.AreEqual( timePeriods.Count, 2 );
            Assert.IsTrue( timePeriods.HasStart );
            Assert.IsTrue( timePeriods.HasEnd );
            Assert.IsTrue( timePeriods.IsMoment );
        }
 public void AddReadOnlyTest()
 {
     TimePeriodChain timePeriods = new TimePeriodChain();
     timePeriods.Add( new TimeRange( TimeSpec.MinPeriodDate, TimeSpec.MaxPeriodDate, true ) );
 }
 public void InsertReadOnlyTest()
 {
     TimePeriodChain timePeriods = new TimePeriodChain();
     timePeriods.Insert( 0, new TimeRange( TimeSpec.MinPeriodDate, TimeSpec.MaxPeriodDate, true ) );
 }
        public void IsAnytimeTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            TimePeriodChain timePeriods = new TimePeriodChain();
            Assert.IsTrue( timePeriods.IsAnytime );

            timePeriods.Add( new TimeBlock( TimeSpec.MinPeriodDate, now ) );
            Assert.IsFalse( timePeriods.IsAnytime );

            timePeriods.Add( new TimeBlock( now, TimeSpec.MaxPeriodDate ) );
            Assert.IsTrue( timePeriods.IsAnytime );
        }
        public void HasEndTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            TimePeriodChain timePeriods = new TimePeriodChain();
            Assert.IsFalse( timePeriods.HasEnd );

            timePeriods.Add( new TimeBlock( Duration.Hour, TimeSpec.MaxPeriodDate ) );
            Assert.IsFalse( timePeriods.HasEnd );

            timePeriods.Clear();
            timePeriods.Add( new TimeBlock( now, Duration.Hour ) );
            Assert.IsTrue( timePeriods.HasEnd );
        }
        public void HasStartTest()
        {
            TimePeriodChain timePeriods = new TimePeriodChain();
            Assert.IsFalse( timePeriods.HasStart );

            timePeriods.Add( new TimeBlock( TimeSpec.MinPeriodDate, Duration.Hour ) );
            Assert.IsFalse( timePeriods.HasStart );

            timePeriods.Clear();
            timePeriods.Add( new TimeBlock( ClockProxy.Clock.Now, Duration.Hour ) );
            Assert.IsTrue( timePeriods.HasStart );
        }
        public void DurationTest()
        {
            TimePeriodChain timePeriods = new TimePeriodChain();
            Assert.AreEqual( timePeriods.Duration, TimeSpec.MaxPeriodDuration );

            TimeSpan duration = Duration.Hour;
            timePeriods.Add( new TimeBlock( ClockProxy.Clock.Now, duration ) );
            Assert.AreEqual( timePeriods.Duration, duration );
        }
        public void EndTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            TimePeriodChain timePeriods = new TimePeriodChain();
            Assert.AreEqual( timePeriods.End, TimeSpec.MaxPeriodDate );

            timePeriods.Add( new TimeBlock( Duration.Hour, now ) );
            Assert.AreEqual( timePeriods.End, now );

            timePeriods.Clear();
            Assert.AreEqual( timePeriods.End, TimeSpec.MaxPeriodDate );
        }
 public void DefaultConstructorTest()
 {
     TimePeriodChain timePeriods = new TimePeriodChain();
     Assert.AreEqual( timePeriods.Count, 0 );
     Assert.IsFalse( timePeriods.HasStart );
     Assert.IsFalse( timePeriods.HasEnd );
     Assert.IsFalse( timePeriods.IsReadOnly );
 }
        public void CopyToTest()
        {
            TimePeriodChain timePeriods = new TimePeriodChain();
            ITimePeriod[] array1 = new ITimePeriod[ 0 ];
            timePeriods.CopyTo( array1, 0 );

            SchoolDay schoolDay = new SchoolDay();
            ITimePeriod[] array2 = new ITimePeriod[ schoolDay.Count ];
            schoolDay.CopyTo( array2, 0 );
            Assert.AreEqual( array2[ 0 ], schoolDay.Lesson1 );
            Assert.AreEqual( array2[ 1 ], schoolDay.Break1 );
            Assert.AreEqual( array2[ 2 ], schoolDay.Lesson2 );
            Assert.AreEqual( array2[ 3 ], schoolDay.Break2 );
            Assert.AreEqual( array2[ 4 ], schoolDay.Lesson3 );
            Assert.AreEqual( array2[ 5 ], schoolDay.Break3 );
            Assert.AreEqual( array2[ 6 ], schoolDay.Lesson4 );

            ITimePeriod[] array3 = new ITimePeriod[ schoolDay.Count + 3 ];
            schoolDay.CopyTo( array3, 3 );
            Assert.AreEqual( array3[ 3 ], schoolDay.Lesson1 );
            Assert.AreEqual( array3[ 4 ], schoolDay.Break1 );
            Assert.AreEqual( array3[ 5 ], schoolDay.Lesson2 );
            Assert.AreEqual( array3[ 6 ], schoolDay.Break2 );
            Assert.AreEqual( array3[ 7 ], schoolDay.Lesson3 );
            Assert.AreEqual( array3[ 8 ], schoolDay.Break3 );
            Assert.AreEqual( array3[ 9 ], schoolDay.Lesson4 );
        }
        public void CopyConstructorTest()
        {
            SchoolDay schoolDay = new SchoolDay();
            TimePeriodChain timePeriods = new TimePeriodChain( schoolDay );
            Assert.AreEqual( timePeriods.Count, schoolDay.Count );
            Assert.IsTrue( timePeriods.HasStart );
            Assert.IsTrue( timePeriods.HasEnd );
            Assert.IsFalse( timePeriods.IsReadOnly );

            Assert.AreEqual( timePeriods.Start, schoolDay.Start );
        }
        public void ContainsPeriodTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodChain timePeriods = new TimePeriodChain( schoolDay );

            TimeRange timeRange = new TimeRange( schoolDay.Lesson1.Start, schoolDay.Lesson1.End );
            Assert.IsFalse( timePeriods.Contains( timeRange ) );
            Assert.IsTrue( timePeriods.ContainsPeriod( timeRange ) );
        }
        public void TimePeriodChainSample()
        {
            TimePeriodChain timePeriods = new TimePeriodChain();

            DateTime now = ClockProxy.Clock.Now;
            DateTime testDay = new DateTime( 2010, 7, 23 );

            // --- add ---
            timePeriods.Add( new TimeBlock( TimeTrim.Hour( testDay, 8 ), Duration.Hours( 2 ) ) );
            timePeriods.Add( new TimeBlock( now, Duration.Hours( 1, 30 ) ) );
            timePeriods.Add( new TimeBlock( now, Duration.Hour ) );
            Console.WriteLine( "TimePeriodChain.Add(): " + timePeriods );
            // > TimePeriodChain.Add(): Count = 3; 23.07.2010 08:00:00 - 12:30:00 | 0.04:30
            foreach ( ITimePeriod timePeriod in timePeriods )
            {
                Console.WriteLine( "Item: " + timePeriod );
            }
            // > Item: 23.07.2010 08:00:00 - 10:00:00 | 02:00:00
            // > Item: 23.07.2010 10:00:00 - 11:30:00 | 01:30:00
            // > Item: 23.07.2010 11:30:00 - 12:30:00 | 01:00:00

            // --- insert ---
            timePeriods.Insert( 2, new TimeBlock( now, Duration.Minutes( 45 ) ) );
            Console.WriteLine( "TimePeriodChain.Insert(): " + timePeriods );
            // > TimePeriodChain.Insert(): Count = 4; 23.07.2010 08:00:00 - 13:15:00 | 0.05:15
            foreach ( ITimePeriod timePeriod in timePeriods )
            {
                Console.WriteLine( "Item: " + timePeriod );
            }
            // > Item: 23.07.2010 08:00:00 - 10:00:00 | 02:00:00
            // > Item: 23.07.2010 10:00:00 - 11:30:00 | 01:30:00
            // > Item: 23.07.2010 11:30:00 - 12:15:00 | 00:45:00
            // > Item: 23.07.2010 12:15:00 - 13:15:00 | 01:00:00
        }