Inheritance: Itenso.TimePeriod.TimePeriodChain
Exemple #1
0
        public void SchoolDayTest()
        {
            DateTime  start     = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay(start);

            Assert.Equal(7, schoolDay.Count);
            Assert.Equal(schoolDay.First, schoolDay.Lesson1);
            Assert.Equal(schoolDay.Last, schoolDay.Lesson4);

            Assert.Equal(schoolDay.Lesson1.Duration, Lesson.LessonDuration);
            Assert.Equal(schoolDay.Lesson1.Start, start);

            Assert.Equal(schoolDay.Break1.Duration, ShortBreak.ShortBreakDuration);
            Assert.Equal(schoolDay.Break1.Start, schoolDay.Lesson1.End);

            Assert.Equal(schoolDay.Lesson2.Duration, Lesson.LessonDuration);
            Assert.Equal(schoolDay.Lesson2.Start, schoolDay.Break1.End);

            Assert.Equal(schoolDay.Break2.Duration, LargeBreak.LargeBreakDuration);
            Assert.Equal(schoolDay.Break2.Start, schoolDay.Lesson2.End);

            Assert.Equal(schoolDay.Lesson3.Duration, Lesson.LessonDuration);
            Assert.Equal(schoolDay.Lesson3.Start, schoolDay.Break2.End);

            Assert.Equal(schoolDay.Break3.Duration, ShortBreak.ShortBreakDuration);
            Assert.Equal(schoolDay.Break3.Start, schoolDay.Lesson3.End);

            Assert.Equal(schoolDay.Lesson4.Duration, Lesson.LessonDuration);
            Assert.Equal(schoolDay.Lesson4.Start, schoolDay.Break3.End);

            Assert.Equal(schoolDay.Start, schoolDay.Lesson1.Start);
            Assert.Equal(schoolDay.End, schoolDay.Lesson4.End);
        } // SchoolDayTest
Exemple #2
0
        public void SchoolDayTest()
        {
            DateTime start = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( start );

            Assert.AreEqual( schoolDay.Count, 7 );
            Assert.AreEqual( schoolDay.First, schoolDay.Lesson1 );
            Assert.AreEqual( schoolDay.Last, schoolDay.Lesson4 );

            Assert.AreEqual( schoolDay.Lesson1.Duration, Lesson.LessonDuration );
            Assert.AreEqual( schoolDay.Lesson1.Start, start );

            Assert.AreEqual( schoolDay.Break1.Duration, ShortBreak.ShortBreakDuration );
            Assert.AreEqual( schoolDay.Break1.Start, schoolDay.Lesson1.End );

            Assert.AreEqual( schoolDay.Lesson2.Duration, Lesson.LessonDuration );
            Assert.AreEqual( schoolDay.Lesson2.Start, schoolDay.Break1.End );

            Assert.AreEqual( schoolDay.Break2.Duration, LargeBreak.LargeBreakDuration );
            Assert.AreEqual( schoolDay.Break2.Start, schoolDay.Lesson2.End );

            Assert.AreEqual( schoolDay.Lesson3.Duration, Lesson.LessonDuration );
            Assert.AreEqual( schoolDay.Lesson3.Start, schoolDay.Break2.End );

            Assert.AreEqual( schoolDay.Break3.Duration, ShortBreak.ShortBreakDuration );
            Assert.AreEqual( schoolDay.Break3.Start, schoolDay.Lesson3.End );

            Assert.AreEqual( schoolDay.Lesson4.Duration, Lesson.LessonDuration );
            Assert.AreEqual( schoolDay.Lesson4.Start, schoolDay.Break3.End );

            Assert.AreEqual( schoolDay.Start, schoolDay.Lesson1.Start );
            Assert.AreEqual( schoolDay.End, schoolDay.Lesson4.End );
        }
        public void InsertTest()
        {
            DateTime             now         = ClockProxy.Clock.Now;
            SchoolDay            schoolDay   = new SchoolDay(now);
            TimePeriodCollection timePeriods = new TimePeriodCollection();

            Assert.AreEqual(timePeriods.Count, 0);

            timePeriods.Add(schoolDay.Lesson1);
            Assert.AreEqual(timePeriods.Count, 1);
            timePeriods.Add(schoolDay.Lesson3);
            Assert.AreEqual(timePeriods.Count, 2);
            timePeriods.Add(schoolDay.Lesson4);
            Assert.AreEqual(timePeriods.Count, 3);

            // between
            Assert.AreEqual(timePeriods[1], schoolDay.Lesson3);
            timePeriods.Insert(1, schoolDay.Lesson2);
            Assert.AreEqual(timePeriods[1], schoolDay.Lesson2);

            // first
            Assert.AreEqual(timePeriods[0], schoolDay.Lesson1);
            timePeriods.Insert(0, schoolDay.Break1);
            Assert.AreEqual(timePeriods[0], schoolDay.Break1);

            // last
            Assert.AreEqual(timePeriods[timePeriods.Count - 1], schoolDay.Lesson4);
            timePeriods.Insert(timePeriods.Count, schoolDay.Break3);
            Assert.AreEqual(timePeriods[timePeriods.Count - 1], schoolDay.Break3);
        }         // InsertTest
        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);
        }         // CopyToTest
        public void GetGapTest()
        {
            DateTime                      now            = ClockProxy.Clock.Now;
            SchoolDay                     schoolDay      = new SchoolDay(now);
            TimePeriodCollection          excludePeriods = new TimePeriodCollection();
            TimeGapCalculator <TimeRange> gapCalculator  = new TimeGapCalculator <TimeRange>();

            excludePeriods.AddAll(schoolDay);

            Assert.AreEqual(gapCalculator.GetGaps(excludePeriods).Count, 0);
            Assert.AreEqual(gapCalculator.GetGaps(excludePeriods, schoolDay).Count, 0);

            excludePeriods.Clear();
            excludePeriods.Add(schoolDay.Lesson1);
            excludePeriods.Add(schoolDay.Lesson2);
            excludePeriods.Add(schoolDay.Lesson3);
            excludePeriods.Add(schoolDay.Lesson4);

            ITimePeriodCollection gaps2 = gapCalculator.GetGaps(excludePeriods);

            Assert.AreEqual(gaps2.Count, 3);
            Assert.IsTrue(gaps2[0].IsSamePeriod(schoolDay.Break1));
            Assert.IsTrue(gaps2[1].IsSamePeriod(schoolDay.Break2));
            Assert.IsTrue(gaps2[2].IsSamePeriod(schoolDay.Break3));

            TimeRange             testRange3 = new TimeRange(schoolDay.Lesson1.Start, schoolDay.Lesson4.End);
            ITimePeriodCollection gaps3      = gapCalculator.GetGaps(excludePeriods, testRange3);

            Assert.AreEqual(gaps3.Count, 3);
            Assert.IsTrue(gaps3[0].IsSamePeriod(schoolDay.Break1));
            Assert.IsTrue(gaps3[1].IsSamePeriod(schoolDay.Break2));
            Assert.IsTrue(gaps3[2].IsSamePeriod(schoolDay.Break3));

            TimeRange             testRange4 = new TimeRange(schoolDay.Start.AddHours(-1), schoolDay.End.AddHours(1));
            ITimePeriodCollection gaps4      = gapCalculator.GetGaps(excludePeriods, testRange4);

            Assert.AreEqual(gaps4.Count, 5);
            Assert.IsTrue(gaps4[0].IsSamePeriod(new TimeRange(testRange4.Start, schoolDay.Start)));
            Assert.IsTrue(gaps4[1].IsSamePeriod(schoolDay.Break1));
            Assert.IsTrue(gaps4[2].IsSamePeriod(schoolDay.Break2));
            Assert.IsTrue(gaps4[3].IsSamePeriod(schoolDay.Break3));
            Assert.IsTrue(gaps4[4].IsSamePeriod(new TimeRange(testRange4.End, testRange3.End)));

            excludePeriods.Clear();
            excludePeriods.Add(schoolDay.Lesson1);
            ITimePeriodCollection gaps8 = gapCalculator.GetGaps(excludePeriods, schoolDay.Lesson1);

            Assert.AreEqual(gaps8.Count, 0);

            TimeRange             testRange9 = new TimeRange(schoolDay.Lesson1.Start.Subtract(new TimeSpan(1)), schoolDay.Lesson1.End.Add(new TimeSpan(1)));
            ITimePeriodCollection gaps9      = gapCalculator.GetGaps(excludePeriods, testRange9);

            Assert.AreEqual(gaps9.Count, 2);
            Assert.AreEqual(gaps9[0].Duration, new TimeSpan(1));
            Assert.AreEqual(gaps9[1].Duration, new TimeSpan(1));
        }         // GetGapsTest
        public void InsertTimeRangeTest()
        {
            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);
        }         // InsertTimeRangeTest
        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 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));
        }         // ContainsPeriodTest
        public void RemoveTest()
        {
            DateTime             now         = ClockProxy.Clock.Now;
            SchoolDay            schoolDay   = new SchoolDay(now);
            TimePeriodCollection timePeriods = new TimePeriodCollection();

            Assert.IsFalse(timePeriods.Contains(schoolDay.Lesson1));
            timePeriods.Add(schoolDay.Lesson1);
            Assert.IsTrue(timePeriods.Contains(schoolDay.Lesson1));
            timePeriods.Remove(schoolDay.Lesson1);
            Assert.IsFalse(timePeriods.Contains(schoolDay.Lesson1));
        }         // RemoveTest
        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);
        }         // CopyConstructorTest
        public void ItemIndexTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            Assert.AreEqual(schoolDay[0], schoolDay.Lesson1);
            Assert.AreEqual(schoolDay[1], schoolDay.Break1);
            Assert.AreEqual(schoolDay[2], schoolDay.Lesson2);
            Assert.AreEqual(schoolDay[3], schoolDay.Break2);
            Assert.AreEqual(schoolDay[4], schoolDay.Lesson3);
            Assert.AreEqual(schoolDay[5], schoolDay.Break3);
            Assert.AreEqual(schoolDay[6], schoolDay.Lesson4);
        }         // ItemIndexTest
        public void StartMoveTest()
        {
            DateTime             now         = ClockProxy.Clock.Now;
            SchoolDay            schoolDay   = new SchoolDay(now);
            TimePeriodCollection timePeriods = new TimePeriodCollection(schoolDay);

            timePeriods.Start = now.AddHours(0);
            Assert.AreEqual(timePeriods.Start, now);
            timePeriods.Start = now.AddHours(1);
            Assert.AreEqual(timePeriods.Start, now.AddHours(1));
            timePeriods.Start = now.AddHours(-1);
            Assert.AreEqual(timePeriods.Start, now.AddHours(-1));
        }         // StartMoveTest
        public void AddAllTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            int count = schoolDay.Count;
            TimeSpan duration = schoolDay.Duration;
            DateTime start = schoolDay.Start;

            schoolDay.AddAll( new SchoolDay() );
            Assert.AreEqual( schoolDay.Count, count + count );
            Assert.AreEqual( schoolDay.Start, start );
            Assert.AreEqual( schoolDay.Duration, duration + duration );
        }
        public void AddAllTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            int      count    = schoolDay.Count;
            TimeSpan duration = schoolDay.Duration;
            DateTime start    = schoolDay.Start;

            schoolDay.AddAll(new SchoolDay());
            Assert.AreEqual(schoolDay.Count, count + count);
            Assert.AreEqual(schoolDay.Start, start);
            Assert.AreEqual(schoolDay.Duration, duration + duration);
        }         // AddAllTest
        public void GetGapTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection excludePeriods = new TimePeriodCollection();
            TimeGapCalculator<TimeRange> gapCalculator = new TimeGapCalculator<TimeRange>();

            excludePeriods.AddAll( schoolDay );

            Assert.AreEqual( gapCalculator.GetGaps( excludePeriods ).Count, 0 );
            Assert.AreEqual( gapCalculator.GetGaps( excludePeriods, schoolDay ).Count, 0 );

            excludePeriods.Clear();
            excludePeriods.Add( schoolDay.Lesson1 );
            excludePeriods.Add( schoolDay.Lesson2 );
            excludePeriods.Add( schoolDay.Lesson3 );
            excludePeriods.Add( schoolDay.Lesson4 );

            ITimePeriodCollection gaps2 = gapCalculator.GetGaps( excludePeriods );
            Assert.AreEqual( gaps2.Count, 3 );
            Assert.IsTrue( gaps2[ 0 ].IsSamePeriod( schoolDay.Break1 ) );
            Assert.IsTrue( gaps2[ 1 ].IsSamePeriod( schoolDay.Break2 ) );
            Assert.IsTrue( gaps2[ 2 ].IsSamePeriod( schoolDay.Break3 ) );

            TimeRange testRange3 = new TimeRange( schoolDay.Lesson1.Start, schoolDay.Lesson4.End );
            ITimePeriodCollection gaps3 = gapCalculator.GetGaps( excludePeriods, testRange3 );
            Assert.AreEqual( gaps3.Count, 3 );
            Assert.IsTrue( gaps3[ 0 ].IsSamePeriod( schoolDay.Break1 ) );
            Assert.IsTrue( gaps3[ 1 ].IsSamePeriod( schoolDay.Break2 ) );
            Assert.IsTrue( gaps3[ 2 ].IsSamePeriod( schoolDay.Break3 ) );

            TimeRange testRange4 = new TimeRange( schoolDay.Start.AddHours( -1 ), schoolDay.End.AddHours( 1 ) );
            ITimePeriodCollection gaps4 = gapCalculator.GetGaps( excludePeriods, testRange4 );
            Assert.AreEqual( gaps4.Count, 5 );
            Assert.IsTrue( gaps4[ 0 ].IsSamePeriod( new TimeRange( testRange4.Start, schoolDay.Start ) ) );
            Assert.IsTrue( gaps4[ 1 ].IsSamePeriod( schoolDay.Break1 ) );
            Assert.IsTrue( gaps4[ 2 ].IsSamePeriod( schoolDay.Break2 ) );
            Assert.IsTrue( gaps4[ 3 ].IsSamePeriod( schoolDay.Break3 ) );
            Assert.IsTrue( gaps4[ 4 ].IsSamePeriod( new TimeRange( testRange4.End, testRange3.End ) ) );

            excludePeriods.Clear();
            excludePeriods.Add( schoolDay.Lesson1 );
            ITimePeriodCollection gaps8 = gapCalculator.GetGaps( excludePeriods, schoolDay.Lesson1 );
            Assert.AreEqual( gaps8.Count, 0 );

            TimeRange testRange9 = new TimeRange( schoolDay.Lesson1.Start.Subtract( new TimeSpan( 1 ) ), schoolDay.Lesson1.End.Add( new TimeSpan( 1 ) ) );
            ITimePeriodCollection gaps9 = gapCalculator.GetGaps( excludePeriods, testRange9 );
            Assert.AreEqual( gaps9.Count, 2 );
            Assert.AreEqual( gaps9[ 0 ].Duration, new TimeSpan( 1 ) );
            Assert.AreEqual( gaps9[ 1 ].Duration, new TimeSpan( 1 ) );
        }
        public void AddAllTest()
        {
            DateTime             now         = ClockProxy.Clock.Now;
            SchoolDay            schoolDay   = new SchoolDay(now);
            TimePeriodCollection timePeriods = new TimePeriodCollection();

            Assert.AreEqual(timePeriods.Count, 0);

            timePeriods.AddAll(schoolDay);
            Assert.AreEqual(timePeriods.Count, schoolDay.Count);

            timePeriods.Clear();
            Assert.AreEqual(timePeriods.Count, 0);
        }         // AddAllTest
        public void AddAllTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection();

            Assert.AreEqual( timePeriods.Count, 0 );

            timePeriods.AddAll( schoolDay );
            Assert.AreEqual( timePeriods.Count, schoolDay.Count );

            timePeriods.Clear();
            Assert.AreEqual( timePeriods.Count, 0 );
        }
        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);
        }         // ClearTest
        public void EndMoveTest()
        {
            DateTime  now       = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay(now);

            DateTime end = schoolDay.End;

            schoolDay.End = end.AddHours(0);
            Assert.AreEqual(schoolDay.End, end);
            schoolDay.End = end.AddHours(1);
            Assert.AreEqual(schoolDay.End, end.AddHours(1));
            schoolDay.End = end.AddHours(-1);
            Assert.AreEqual(schoolDay.End, end.AddHours(-1));
        }         // EndMoveTest
        public void StartMoveTest()
        {
            DateTime  now       = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay(now);

            Assert.AreEqual(schoolDay.Start, now);

            schoolDay.Start = now.AddHours(0);
            Assert.AreEqual(schoolDay.Start, now);
            schoolDay.Start = now.AddHours(1);
            Assert.AreEqual(schoolDay.Start, now.AddHours(1));
            schoolDay.Start = now.AddHours(-1);
            Assert.AreEqual(schoolDay.Start, now.AddHours(-1));
        }         // StartMoveTest
        public void ClearTest()
        {
            TimePeriodChain timePeriods = new TimePeriodChain();

            Assert.Equal(0, timePeriods.Count);
            timePeriods.Clear();
            Assert.Equal(0, timePeriods.Count);

            SchoolDay schoolDay = new SchoolDay();

            Assert.Equal(7, schoolDay.Count);
            schoolDay.Clear();
            Assert.Equal(0, schoolDay.Count);
        }         // ClearTest
        public void ItemIndexTest()
        {
            TimePeriodCollection timePeriods = new TimePeriodCollection();
            SchoolDay            schoolDay   = new SchoolDay();

            timePeriods.AddAll(schoolDay);

            Assert.AreEqual(timePeriods[0], schoolDay.Lesson1);
            Assert.AreEqual(timePeriods[1], schoolDay.Break1);
            Assert.AreEqual(timePeriods[2], schoolDay.Lesson2);
            Assert.AreEqual(timePeriods[3], schoolDay.Break2);
            Assert.AreEqual(timePeriods[4], schoolDay.Lesson3);
            Assert.AreEqual(timePeriods[5], schoolDay.Break3);
            Assert.AreEqual(timePeriods[6], schoolDay.Lesson4);
        }         // ItemIndexTest
        public void AddTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            int count = schoolDay.Count;
            DateTime end = schoolDay.End;
            ShortBreak shortBreak = new ShortBreak( schoolDay.Start );
            schoolDay.Add( shortBreak );
            Assert.AreEqual( schoolDay.Count, count + 1 );
            Assert.AreEqual( schoolDay.Last, shortBreak );
            Assert.AreEqual( schoolDay.End, end.Add( shortBreak.Duration ) );
            Assert.AreEqual( shortBreak.Start, end );
            Assert.AreEqual( shortBreak.End, schoolDay.End );
            Assert.AreEqual( shortBreak.Duration, ShortBreak.ShortBreakDuration );
        }
        public void EndMoveTest()
        {
            DateTime             now         = ClockProxy.Clock.Now;
            SchoolDay            schoolDay   = new SchoolDay(now);
            TimePeriodCollection timePeriods = new TimePeriodCollection(schoolDay);

            DateTime end = schoolDay.End;

            timePeriods.End = end.AddHours(0);
            Assert.AreEqual(timePeriods.End, end);
            timePeriods.End = end.AddHours(1);
            Assert.AreEqual(timePeriods.End, end.AddHours(1));
            timePeriods.End = end.AddHours(-1);
            Assert.AreEqual(timePeriods.End, end.AddHours(-1));
        }         // EndMoveTest
        public void CopyToTest()
        {
            DateTime             now         = ClockProxy.Clock.Now;
            SchoolDay            schoolDay   = new SchoolDay(now);
            TimePeriodCollection timePeriods = new TimePeriodCollection(schoolDay);

            ITimePeriod[] array = new ITimePeriod[schoolDay.Count];
            timePeriods.CopyTo(array, 0);
            Assert.AreEqual(array[0], schoolDay.Lesson1);
            Assert.AreEqual(array[1], schoolDay.Break1);
            Assert.AreEqual(array[2], schoolDay.Lesson2);
            Assert.AreEqual(array[3], schoolDay.Break2);
            Assert.AreEqual(array[4], schoolDay.Lesson3);
            Assert.AreEqual(array[5], schoolDay.Break3);
            Assert.AreEqual(array[6], schoolDay.Lesson4);
        }         // CopyToTest
        public void MoveTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            DateTime startDate     = schoolDay.Start;
            DateTime endDate       = schoolDay.End;
            TimeSpan startDuration = schoolDay.Duration;

            TimeSpan duration = Duration.Hour;

            schoolDay.Move(duration);

            Assert.AreEqual(schoolDay.Start, startDate.Add(duration));
            Assert.AreEqual(schoolDay.End, endDate.Add(duration));
            Assert.AreEqual(schoolDay.Duration, startDuration);
        }         // MoveTest
        public void IsSamePeriodTest()
        {
            SchoolDay schoolDay   = new SchoolDay();
            TimeRange manualRange = new TimeRange(schoolDay.Start, schoolDay.End);

            Assert.IsTrue(schoolDay.IsSamePeriod(schoolDay));
            Assert.IsTrue(schoolDay.IsSamePeriod(manualRange));
            Assert.IsTrue(manualRange.IsSamePeriod(schoolDay));

            Assert.IsFalse(schoolDay.IsSamePeriod(TimeBlock.Anytime));
            Assert.IsFalse(manualRange.IsSamePeriod(TimeBlock.Anytime));

            schoolDay.RemoveAt(0);
            Assert.IsFalse(schoolDay.IsSamePeriod(manualRange));
            Assert.IsFalse(manualRange.IsSamePeriod(schoolDay));
        }         // IsSamePeriodTest
        public void AddTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            int        count      = schoolDay.Count;
            DateTime   end        = schoolDay.End;
            ShortBreak shortBreak = new ShortBreak(schoolDay.Start);

            schoolDay.Add(shortBreak);
            Assert.AreEqual(schoolDay.Count, count + 1);
            Assert.AreEqual(schoolDay.Last, shortBreak);
            Assert.AreEqual(schoolDay.End, end.Add(shortBreak.Duration));
            Assert.AreEqual(shortBreak.Start, end);
            Assert.AreEqual(shortBreak.End, schoolDay.End);
            Assert.AreEqual(shortBreak.Duration, ShortBreak.ShortBreakDuration);
        }         // AddTest
        public void MoveTest()
        {
            DateTime             now         = ClockProxy.Clock.Now;
            SchoolDay            schoolDay   = new SchoolDay(now);
            TimePeriodCollection timePeriods = new TimePeriodCollection(schoolDay);

            DateTime startDate     = schoolDay.Start;
            DateTime endDate       = schoolDay.End;
            TimeSpan startDuration = timePeriods.Duration;

            TimeSpan duration = Duration.Hour;

            timePeriods.Move(duration);

            Assert.AreEqual(timePeriods.Start, startDate.Add(duration));
            Assert.AreEqual(timePeriods.End, endDate.Add(duration));
            Assert.AreEqual(timePeriods.Duration, startDuration);
        }         // MoveTest
        public void SortByEndTest()
        {
            DateTime             now         = ClockProxy.Clock.Now;
            SchoolDay            schoolDay   = new SchoolDay(now);
            TimePeriodCollection timePeriods = new TimePeriodCollection();

            timePeriods.AddAll(schoolDay);

            timePeriods.SortByEnd();

            Assert.AreEqual(timePeriods[0], schoolDay.Lesson4);
            Assert.AreEqual(timePeriods[1], schoolDay.Break3);
            Assert.AreEqual(timePeriods[2], schoolDay.Lesson3);
            Assert.AreEqual(timePeriods[3], schoolDay.Break2);
            Assert.AreEqual(timePeriods[4], schoolDay.Lesson2);
            Assert.AreEqual(timePeriods[5], schoolDay.Break1);
            Assert.AreEqual(timePeriods[6], schoolDay.Lesson1);
        }         // SortByEndTest
        public void IndexOfTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            Assert.AreEqual(schoolDay.IndexOf(new TimeRange()), -1);
            Assert.AreEqual(schoolDay.IndexOf(new TimeBlock()), -1);

            Assert.AreEqual(schoolDay.IndexOf(schoolDay.Lesson1), 0);
            Assert.AreEqual(schoolDay.IndexOf(schoolDay.Break1), 1);
            Assert.AreEqual(schoolDay.IndexOf(schoolDay.Lesson2), 2);
            Assert.AreEqual(schoolDay.IndexOf(schoolDay.Break2), 3);
            Assert.AreEqual(schoolDay.IndexOf(schoolDay.Lesson3), 4);
            Assert.AreEqual(schoolDay.IndexOf(schoolDay.Break3), 5);
            Assert.AreEqual(schoolDay.IndexOf(schoolDay.Lesson4), 6);

            schoolDay.Remove(schoolDay.Lesson1);
            Assert.AreEqual(schoolDay.IndexOf(schoolDay.Lesson1), -1);
        }         // IndexOfTest
        public void ContainsTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            Assert.IsFalse(schoolDay.Contains(new TimeRange()));
            Assert.IsFalse(schoolDay.Contains(new TimeBlock()));

            Assert.IsTrue(schoolDay.Contains(schoolDay.Lesson1));
            Assert.IsTrue(schoolDay.Contains(schoolDay.Break1));
            Assert.IsTrue(schoolDay.Contains(schoolDay.Lesson2));
            Assert.IsTrue(schoolDay.Contains(schoolDay.Break2));
            Assert.IsTrue(schoolDay.Contains(schoolDay.Lesson3));
            Assert.IsTrue(schoolDay.Contains(schoolDay.Break3));
            Assert.IsTrue(schoolDay.Contains(schoolDay.Lesson4));

            schoolDay.Remove(schoolDay.Lesson1);
            Assert.IsFalse(schoolDay.Contains(schoolDay.Lesson1));
        }         // ContainsTest
        public void IsSamePeriodTest()
        {
            DateTime             now         = ClockProxy.Clock.Now;
            SchoolDay            schoolDay   = new SchoolDay(now);
            TimePeriodCollection timePeriods = new TimePeriodCollection(schoolDay);

            Assert.IsTrue(timePeriods.IsSamePeriod(timePeriods));
            Assert.IsTrue(timePeriods.IsSamePeriod(schoolDay));

            Assert.IsTrue(schoolDay.IsSamePeriod(schoolDay));
            Assert.IsTrue(schoolDay.IsSamePeriod(timePeriods));

            Assert.IsFalse(timePeriods.IsSamePeriod(TimeBlock.Anytime));
            Assert.IsFalse(schoolDay.IsSamePeriod(TimeBlock.Anytime));

            timePeriods.RemoveAt(0);
            Assert.IsFalse(timePeriods.IsSamePeriod(schoolDay));
        }         // IsSamePeriodTest
        public void IndexOfTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            Assert.Equal(schoolDay.IndexOf(new TimeRange()), -1);
            Assert.Equal(schoolDay.IndexOf(new TimeBlock()), -1);

            Assert.Equal(0, schoolDay.IndexOf(schoolDay.Lesson1));
            Assert.Equal(1, schoolDay.IndexOf(schoolDay.Break1));
            Assert.Equal(2, schoolDay.IndexOf(schoolDay.Lesson2));
            Assert.Equal(3, schoolDay.IndexOf(schoolDay.Break2));
            Assert.Equal(4, schoolDay.IndexOf(schoolDay.Lesson3));
            Assert.Equal(5, schoolDay.IndexOf(schoolDay.Break3));
            Assert.Equal(6, schoolDay.IndexOf(schoolDay.Lesson4));

            schoolDay.Remove(schoolDay.Lesson1);
            Assert.Equal(schoolDay.IndexOf(schoolDay.Lesson1), -1);
        }         // IndexOfTest
        public void InsertTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            // first
            int      count   = schoolDay.Count;
            DateTime start   = schoolDay.Start;
            Lesson   lesson1 = new Lesson(schoolDay.Start);

            schoolDay.Insert(0, lesson1);
            Assert.AreEqual(schoolDay.Count, count + 1);
            Assert.AreEqual(schoolDay[0], lesson1);
            Assert.AreEqual(schoolDay.First, lesson1);
            Assert.AreEqual(schoolDay.Start, start.Subtract(lesson1.Duration));
            Assert.AreEqual(lesson1.Start, schoolDay.Start);
            Assert.AreEqual(lesson1.End, start);
            Assert.AreEqual(lesson1.Duration, Lesson.LessonDuration);

            // inside
            count = schoolDay.Count;
            start = schoolDay.Start;
            ShortBreak shortBreak1 = new ShortBreak(schoolDay.Start);

            schoolDay.Insert(1, shortBreak1);
            Assert.AreEqual(schoolDay.Count, count + 1);
            Assert.AreEqual(schoolDay[1], shortBreak1);
            Assert.AreEqual(schoolDay.First, lesson1);
            Assert.AreEqual(schoolDay.Start, start);
            Assert.AreEqual(shortBreak1.Start, schoolDay.Start.Add(lesson1.Duration));
            Assert.AreEqual(shortBreak1.Duration, ShortBreak.ShortBreakDuration);

            // last
            count = schoolDay.Count;
            DateTime   end         = schoolDay.End;
            ShortBreak shortBreak2 = new ShortBreak(schoolDay.Start);

            schoolDay.Insert(schoolDay.Count, shortBreak2);
            Assert.AreEqual(schoolDay.Count, count + 1);
            Assert.AreEqual(schoolDay[count], shortBreak2);
            Assert.AreEqual(schoolDay.Last, shortBreak2);
            Assert.AreEqual(schoolDay.End, shortBreak2.End);
            Assert.AreEqual(shortBreak2.Start, end);
            Assert.AreEqual(shortBreak2.Duration, ShortBreak.ShortBreakDuration);
        }         // InsertTest
        public void RemoveAtTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            // first
            int         count      = schoolDay.Count;
            DateTime    end        = schoolDay.End;
            ITimePeriod removeItem = schoolDay[0];
            TimeSpan    duration   = schoolDay.Duration;

            schoolDay.RemoveAt(0);
            Assert.AreEqual(schoolDay.Count, count - 1);
            Assert.AreNotEqual(schoolDay[0], removeItem);
            Assert.AreEqual(schoolDay.End, end);
            Assert.AreEqual(schoolDay.Duration, duration.Subtract(removeItem.Duration));

            // inside
            count    = schoolDay.Count;
            duration = schoolDay.Duration;
            DateTime    start = schoolDay.Start;
            ITimePeriod first = schoolDay.First;
            ITimePeriod last  = schoolDay.Last;

            removeItem = schoolDay[1];
            schoolDay.RemoveAt(1);
            Assert.AreEqual(schoolDay.Count, count - 1);
            Assert.AreNotEqual(schoolDay[1], removeItem);
            Assert.AreEqual(schoolDay.First, first);
            Assert.AreEqual(schoolDay.Start, start);
            Assert.AreEqual(schoolDay.Last, last);
            Assert.AreEqual(schoolDay.Duration, duration.Subtract(removeItem.Duration));

            // last
            count      = schoolDay.Count;
            start      = schoolDay.Start;
            duration   = schoolDay.Duration;
            removeItem = schoolDay[schoolDay.Count - 1];
            schoolDay.RemoveAt(schoolDay.Count - 1);
            Assert.AreEqual(schoolDay.Count, count - 1);
            Assert.AreNotEqual(schoolDay[schoolDay.Count - 1], removeItem);
            Assert.AreEqual(schoolDay.Start, start);
            Assert.AreEqual(schoolDay.Duration, duration.Subtract(removeItem.Duration));
        }         // RemoveAtTest
        public void StartMoveTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            Assert.AreEqual( schoolDay.Start, now );

            schoolDay.Start = now.AddHours( 0 );
            Assert.AreEqual( schoolDay.Start, now );
            schoolDay.Start = now.AddHours( 1 );
            Assert.AreEqual( schoolDay.Start, now.AddHours( 1 ) );
            schoolDay.Start = now.AddHours( -1 );
            Assert.AreEqual( schoolDay.Start, now.AddHours( -1 ) );
        }
        public void IndexOfTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection();

            Assert.AreEqual( timePeriods.IndexOf( new TimeRange() ), -1 );
            Assert.AreEqual( timePeriods.IndexOf( new TimeBlock() ), -1 );

            timePeriods.AddAll( schoolDay );

            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Lesson1 ), 0 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Break1 ), 1 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Lesson2 ), 2 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Break2 ), 3 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Lesson3 ), 4 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Break3 ), 5 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Lesson4 ), 6 );

            timePeriods.Remove( schoolDay.Lesson1 );
            Assert.AreEqual( timePeriods.IndexOf( schoolDay.Lesson1 ), -1 );
        }
        public void InsertTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection();
            Assert.AreEqual( timePeriods.Count, 0 );

            timePeriods.Add( schoolDay.Lesson1 );
            Assert.AreEqual( timePeriods.Count, 1 );
            timePeriods.Add( schoolDay.Lesson3 );
            Assert.AreEqual( timePeriods.Count, 2 );
            timePeriods.Add( schoolDay.Lesson4 );
            Assert.AreEqual( timePeriods.Count, 3 );

            // between
            Assert.AreEqual( timePeriods[ 1 ], schoolDay.Lesson3 );
            timePeriods.Insert( 1, schoolDay.Lesson2 );
            Assert.AreEqual( timePeriods[ 1 ], schoolDay.Lesson2 );

            // first
            Assert.AreEqual( timePeriods[ 0 ], schoolDay.Lesson1 );
            timePeriods.Insert( 0, schoolDay.Break1 );
            Assert.AreEqual( timePeriods[ 0 ], schoolDay.Break1 );

            // last
            Assert.AreEqual( timePeriods[ timePeriods.Count - 1 ], schoolDay.Lesson4 );
            timePeriods.Insert( timePeriods.Count, schoolDay.Break3 );
            Assert.AreEqual( timePeriods[ timePeriods.Count - 1 ], schoolDay.Break3 );
        }
        public void InsertTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            // first
            int count = schoolDay.Count;
            DateTime start = schoolDay.Start;
            Lesson lesson1 = new Lesson( schoolDay.Start );
            schoolDay.Insert( 0, lesson1 );
            Assert.AreEqual( schoolDay.Count, count + 1 );
            Assert.AreEqual( schoolDay[ 0 ], lesson1 );
            Assert.AreEqual( schoolDay.First, lesson1 );
            Assert.AreEqual( schoolDay.Start, start.Subtract( lesson1.Duration ) );
            Assert.AreEqual( lesson1.Start, schoolDay.Start );
            Assert.AreEqual( lesson1.End, start );
            Assert.AreEqual( lesson1.Duration, Lesson.LessonDuration );

            // inside
            count = schoolDay.Count;
            start = schoolDay.Start;
            ShortBreak shortBreak1 = new ShortBreak( schoolDay.Start );
            schoolDay.Insert( 1, shortBreak1 );
            Assert.AreEqual( schoolDay.Count, count + 1 );
            Assert.AreEqual( schoolDay[ 1 ], shortBreak1 );
            Assert.AreEqual( schoolDay.First, lesson1 );
            Assert.AreEqual( schoolDay.Start, start );
            Assert.AreEqual( shortBreak1.Start, schoolDay.Start.Add( lesson1.Duration ) );
            Assert.AreEqual( shortBreak1.Duration, ShortBreak.ShortBreakDuration );

            // last
            count = schoolDay.Count;
            DateTime end = schoolDay.End;
            ShortBreak shortBreak2 = new ShortBreak( schoolDay.Start );
            schoolDay.Insert( schoolDay.Count, shortBreak2 );
            Assert.AreEqual( schoolDay.Count, count + 1 );
            Assert.AreEqual( schoolDay[ count ], shortBreak2 );
            Assert.AreEqual( schoolDay.Last, shortBreak2 );
            Assert.AreEqual( schoolDay.End, shortBreak2.End );
            Assert.AreEqual( shortBreak2.Start, end );
            Assert.AreEqual( shortBreak2.Duration, ShortBreak.ShortBreakDuration );
        }
        public void EndMoveTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection( schoolDay );

            DateTime end = schoolDay.End;
            timePeriods.End = end.AddHours( 0 );
            Assert.AreEqual( timePeriods.End, end );
            timePeriods.End = end.AddHours( 1 );
            Assert.AreEqual( timePeriods.End, end.AddHours( 1 ) );
            timePeriods.End = end.AddHours( -1 );
            Assert.AreEqual( timePeriods.End, end.AddHours( -1 ) );
        }
        public void RemoveTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection();

            Assert.IsFalse( timePeriods.Contains( schoolDay.Lesson1 ) );
            timePeriods.Add( schoolDay.Lesson1 );
            Assert.IsTrue( timePeriods.Contains( schoolDay.Lesson1 ) );
            timePeriods.Remove( schoolDay.Lesson1 );
            Assert.IsFalse( timePeriods.Contains( schoolDay.Lesson1 ) );
        }
        public void StartMoveTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection( schoolDay );

            timePeriods.Start = now.AddHours( 0 );
            Assert.AreEqual( timePeriods.Start, now );
            timePeriods.Start = now.AddHours( 1 );
            Assert.AreEqual( timePeriods.Start, now.AddHours( 1 ) );
            timePeriods.Start = now.AddHours( -1 );
            Assert.AreEqual( timePeriods.Start, now.AddHours( -1 ) );
        }
        public void IsSamePeriodTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection( schoolDay );

            Assert.IsTrue( timePeriods.IsSamePeriod( timePeriods ) );
            Assert.IsTrue( timePeriods.IsSamePeriod( schoolDay ) );

            Assert.IsTrue( schoolDay.IsSamePeriod( schoolDay ) );
            Assert.IsTrue( schoolDay.IsSamePeriod( timePeriods ) );

            Assert.IsFalse( timePeriods.IsSamePeriod( TimeBlock.Anytime ) );
            Assert.IsFalse( schoolDay.IsSamePeriod( TimeBlock.Anytime ) );

            timePeriods.RemoveAt( 0 );
            Assert.IsFalse( timePeriods.IsSamePeriod( schoolDay ) );
        }
        public void MoveTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection( schoolDay );

            DateTime startDate = schoolDay.Start;
            DateTime endDate = schoolDay.End;
            TimeSpan startDuration = timePeriods.Duration;

            TimeSpan duration = Duration.Hour;
            timePeriods.Move( duration );

            Assert.AreEqual( timePeriods.Start, startDate.Add( duration ) );
            Assert.AreEqual( timePeriods.End, endDate.Add( duration ) );
            Assert.AreEqual( timePeriods.Duration, startDuration );
        }
        public void GetRelationTest()
        {
            SchoolDay schoolDay = new SchoolDay();
            TimeSpan offset = Duration.Second;
            TimeRangePeriodRelationTestData testData = new TimeRangePeriodRelationTestData( schoolDay.Start, schoolDay.End, offset );

            Assert.AreEqual( schoolDay.GetRelation( testData.Before ), PeriodRelation.Before );
            Assert.AreEqual( schoolDay.GetRelation( testData.StartTouching ), PeriodRelation.StartTouching );
            Assert.AreEqual( schoolDay.GetRelation( testData.StartInside ), PeriodRelation.StartInside );
            Assert.AreEqual( schoolDay.GetRelation( testData.InsideStartTouching ), PeriodRelation.InsideStartTouching );
            Assert.AreEqual( schoolDay.GetRelation( testData.EnclosingStartTouching ), PeriodRelation.EnclosingStartTouching );
            Assert.AreEqual( schoolDay.GetRelation( testData.Enclosing ), PeriodRelation.Enclosing );
            Assert.AreEqual( schoolDay.GetRelation( testData.EnclosingEndTouching ), PeriodRelation.EnclosingEndTouching );
            Assert.AreEqual( schoolDay.GetRelation( testData.ExactMatch ), PeriodRelation.ExactMatch );
            Assert.AreEqual( schoolDay.GetRelation( testData.Inside ), PeriodRelation.Inside );
            Assert.AreEqual( schoolDay.GetRelation( testData.InsideEndTouching ), PeriodRelation.InsideEndTouching );
            Assert.AreEqual( schoolDay.GetRelation( testData.EndInside ), PeriodRelation.EndInside );
            Assert.AreEqual( schoolDay.GetRelation( testData.EndTouching ), PeriodRelation.EndTouching );
            Assert.AreEqual( schoolDay.GetRelation( testData.After ), PeriodRelation.After );
        }
        public void RemoveTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            // first
            int count = schoolDay.Count;
            DateTime end = schoolDay.End;
            ITimePeriod removeItem = schoolDay.First;
            TimeSpan duration = schoolDay.Duration;
            schoolDay.Remove( removeItem );
            Assert.AreEqual( schoolDay.Count, count - 1 );
            Assert.AreNotEqual( schoolDay.First, removeItem );
            Assert.AreEqual( schoolDay.End, end );
            Assert.AreEqual( schoolDay.Duration, duration.Subtract( removeItem.Duration ) );

            // inside
            count = schoolDay.Count;
            duration = schoolDay.Duration;
            DateTime start = schoolDay.Start;
            ITimePeriod first = schoolDay.First;
            ITimePeriod last = schoolDay.Last;
            removeItem = schoolDay[ 1 ];
            schoolDay.Remove( removeItem );
            Assert.AreEqual( schoolDay.Count, count - 1 );
            Assert.AreNotEqual( schoolDay[ 1 ], removeItem );
            Assert.AreEqual( schoolDay.First, first );
            Assert.AreEqual( schoolDay.Start, start );
            Assert.AreEqual( schoolDay.Last, last );
            Assert.AreEqual( schoolDay.Duration, duration.Subtract( removeItem.Duration ) );

            // last
            count = schoolDay.Count;
            start = schoolDay.Start;
            duration = schoolDay.Duration;
            removeItem = schoolDay.Last;
            schoolDay.Remove( removeItem );
            Assert.AreEqual( schoolDay.Count, count - 1 );
            Assert.AreNotEqual( schoolDay.Last, removeItem );
            Assert.AreEqual( schoolDay.Start, start );
            Assert.AreEqual( schoolDay.Duration, duration.Subtract( removeItem.Duration ) );
        }
        public void OverlapsWithTest()
        {
            SchoolDay schoolDay = new SchoolDay();
            TimeSpan offset = Duration.Second;
            TimeRangePeriodRelationTestData testData = new TimeRangePeriodRelationTestData( schoolDay.Start, schoolDay.End, offset );

            Assert.IsFalse( schoolDay.OverlapsWith( testData.Before ) );
            Assert.IsFalse( schoolDay.OverlapsWith( testData.StartTouching ) );
            Assert.IsTrue( schoolDay.OverlapsWith( testData.StartInside ) );
            Assert.IsTrue( schoolDay.OverlapsWith( testData.InsideStartTouching ) );
            Assert.IsTrue( schoolDay.OverlapsWith( testData.EnclosingStartTouching ) );
            Assert.IsTrue( schoolDay.OverlapsWith( testData.Enclosing ) );
            Assert.IsTrue( schoolDay.OverlapsWith( testData.EnclosingEndTouching ) );
            Assert.IsTrue( schoolDay.OverlapsWith( testData.ExactMatch ) );
            Assert.IsTrue( schoolDay.OverlapsWith( testData.Inside ) );
            Assert.IsTrue( schoolDay.OverlapsWith( testData.InsideEndTouching ) );
            Assert.IsTrue( schoolDay.OverlapsWith( testData.EndInside ) );
            Assert.IsFalse( schoolDay.OverlapsWith( testData.EndTouching ) );
            Assert.IsFalse( schoolDay.OverlapsWith( testData.After ) );
        }
        public void MoveTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            DateTime startDate = schoolDay.Start;
            DateTime endDate = schoolDay.End;
            TimeSpan startDuration = schoolDay.Duration;

            TimeSpan duration = Duration.Hour;
            schoolDay.Move( duration );

            Assert.AreEqual( schoolDay.Start, startDate.Add( duration ) );
            Assert.AreEqual( schoolDay.End, endDate.Add( duration ) );
            Assert.AreEqual( schoolDay.Duration, startDuration );
        }
 public void LastTest()
 {
     SchoolDay schoolDay = new SchoolDay();
     Assert.AreEqual( schoolDay.Last, schoolDay.Lesson4 );
 }
 public void ItemIndexTest()
 {
     SchoolDay schoolDay = new SchoolDay();
     Assert.AreEqual( schoolDay[ 0 ], schoolDay.Lesson1 );
     Assert.AreEqual( schoolDay[ 1 ], schoolDay.Break1 );
     Assert.AreEqual( schoolDay[ 2 ], schoolDay.Lesson2 );
     Assert.AreEqual( schoolDay[ 3 ], schoolDay.Break2 );
     Assert.AreEqual( schoolDay[ 4 ], schoolDay.Lesson3 );
     Assert.AreEqual( schoolDay[ 5 ], schoolDay.Break3 );
     Assert.AreEqual( schoolDay[ 6 ], schoolDay.Lesson4 );
 }
        public void IsSamePeriodTest()
        {
            SchoolDay schoolDay = new SchoolDay();
            TimeRange manualRange = new TimeRange( schoolDay.Start, schoolDay.End );

            Assert.IsTrue( schoolDay.IsSamePeriod( schoolDay ) );
            Assert.IsTrue( schoolDay.IsSamePeriod( manualRange ) );
            Assert.IsTrue( manualRange.IsSamePeriod( schoolDay ) );

            Assert.IsFalse( schoolDay.IsSamePeriod( TimeBlock.Anytime ) );
            Assert.IsFalse( manualRange.IsSamePeriod( TimeBlock.Anytime ) );

            schoolDay.RemoveAt( 0 );
            Assert.IsFalse( schoolDay.IsSamePeriod( manualRange ) );
            Assert.IsFalse( manualRange.IsSamePeriod( schoolDay ) );
        }
        public void ItemIndexTest()
        {
            TimePeriodCollection timePeriods = new TimePeriodCollection();
            SchoolDay schoolDay = new SchoolDay();
            timePeriods.AddAll( schoolDay );

            Assert.AreEqual( timePeriods[ 0 ], schoolDay.Lesson1 );
            Assert.AreEqual( timePeriods[ 1 ], schoolDay.Break1 );
            Assert.AreEqual( timePeriods[ 2 ], schoolDay.Lesson2 );
            Assert.AreEqual( timePeriods[ 3 ], schoolDay.Break2 );
            Assert.AreEqual( timePeriods[ 4 ], schoolDay.Lesson3 );
            Assert.AreEqual( timePeriods[ 5 ], schoolDay.Break3 );
            Assert.AreEqual( timePeriods[ 6 ], schoolDay.Lesson4 );
        }
        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 RemoveAtTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection( schoolDay );

            // inside
            Assert.AreEqual( timePeriods[ 2 ], schoolDay.Lesson2 );
            timePeriods.RemoveAt( 2 );
            Assert.AreEqual( timePeriods[ 2 ], schoolDay.Break2 );

            // first
            Assert.AreEqual( timePeriods[ 0 ], schoolDay.Lesson1 );
            timePeriods.RemoveAt( 0 );
            Assert.AreEqual( timePeriods[ 0 ], schoolDay.Break1 );

            // last
            Assert.AreEqual( timePeriods[ timePeriods.Count - 1 ], schoolDay.Lesson4 );
            timePeriods.RemoveAt( timePeriods.Count - 1 );
            Assert.AreEqual( timePeriods[ timePeriods.Count - 1 ], schoolDay.Break3 );
        }
        public void ContainsPeriodTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection( schoolDay );

            TimeRange timeRange = new TimeRange( schoolDay.Lesson1.Start, schoolDay.Lesson1.End );
            Assert.IsFalse( timePeriods.Contains( timeRange ) );
            Assert.IsTrue( timePeriods.ContainsPeriod( timeRange ) );

            timePeriods.Add( timeRange );
            Assert.IsTrue( timePeriods.Contains( timeRange ) );
            Assert.IsTrue( timePeriods.ContainsPeriod( timeRange ) );
        }
        public void SortByStartTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection();

            timePeriods.Add( schoolDay.Lesson4 );
            timePeriods.Add( schoolDay.Break3 );
            timePeriods.Add( schoolDay.Lesson3 );
            timePeriods.Add( schoolDay.Break2 );
            timePeriods.Add( schoolDay.Lesson2 );
            timePeriods.Add( schoolDay.Break1 );
            timePeriods.Add( schoolDay.Lesson1 );

            timePeriods.SortByStart();

            Assert.AreEqual( timePeriods[ 0 ], schoolDay.Lesson1 );
            Assert.AreEqual( timePeriods[ 1 ], schoolDay.Break1 );
            Assert.AreEqual( timePeriods[ 2 ], schoolDay.Lesson2 );
            Assert.AreEqual( timePeriods[ 3 ], schoolDay.Break2 );
            Assert.AreEqual( timePeriods[ 4 ], schoolDay.Lesson3 );
            Assert.AreEqual( timePeriods[ 5 ], schoolDay.Break3 );
            Assert.AreEqual( timePeriods[ 6 ], schoolDay.Lesson4 );
        }
        public void CopyToTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay( now );
            TimePeriodCollection timePeriods = new TimePeriodCollection( schoolDay );

            ITimePeriod[] array = new ITimePeriod[ schoolDay.Count ];
            timePeriods.CopyTo( array, 0 );
            Assert.AreEqual( array[ 0 ], schoolDay.Lesson1 );
            Assert.AreEqual( array[ 1 ], schoolDay.Break1 );
            Assert.AreEqual( array[ 2 ], schoolDay.Lesson2 );
            Assert.AreEqual( array[ 3 ], schoolDay.Break2 );
            Assert.AreEqual( array[ 4 ], schoolDay.Lesson3 );
            Assert.AreEqual( array[ 5 ], schoolDay.Break3 );
            Assert.AreEqual( array[ 6 ], schoolDay.Lesson4 );
        }
 public void FirstTest()
 {
     SchoolDay schoolDay = new SchoolDay();
     Assert.AreEqual( schoolDay.First, schoolDay.Lesson1 );
 }
        public void IndexOfTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            Assert.AreEqual( schoolDay.IndexOf( new TimeRange() ), -1 );
            Assert.AreEqual( schoolDay.IndexOf( new TimeBlock() ), -1 );

            Assert.AreEqual( schoolDay.IndexOf( schoolDay.Lesson1 ), 0 );
            Assert.AreEqual( schoolDay.IndexOf( schoolDay.Break1 ), 1 );
            Assert.AreEqual( schoolDay.IndexOf( schoolDay.Lesson2 ), 2 );
            Assert.AreEqual( schoolDay.IndexOf( schoolDay.Break2 ), 3 );
            Assert.AreEqual( schoolDay.IndexOf( schoolDay.Lesson3 ), 4 );
            Assert.AreEqual( schoolDay.IndexOf( schoolDay.Break3 ), 5 );
            Assert.AreEqual( schoolDay.IndexOf( schoolDay.Lesson4 ), 6 );

            schoolDay.Remove( schoolDay.Lesson1 );
            Assert.AreEqual( schoolDay.IndexOf( schoolDay.Lesson1 ), -1 );
        }