Beispiel #1
0
        public void InsertTest()
        {
            var now         = ClockProxy.Clock.Now;
            var schoolDay   = new SchoolDay(now);
            var timePeriods = new TimePeriodCollection();

            timePeriods.Count.Should().Be(0);

            timePeriods.Add(schoolDay.Lesson1);
            timePeriods.Count.Should().Be(1);
            timePeriods.Add(schoolDay.Lesson3);
            timePeriods.Count.Should().Be(2);
            timePeriods.Add(schoolDay.Lesson4);
            timePeriods.Count.Should().Be(3);

            // between
            timePeriods[1].Should().Be(schoolDay.Lesson3);
            timePeriods.Insert(1, schoolDay.Lesson2);
            timePeriods[1].Should().Be(schoolDay.Lesson2);

            // first
            timePeriods[0].Should().Be(schoolDay.Lesson1);
            timePeriods.Insert(0, schoolDay.Break1);
            timePeriods[0].Should().Be(schoolDay.Break1);

            // last
            timePeriods[timePeriods.Count - 1].Should().Be(schoolDay.Lesson4);
            timePeriods.Insert(timePeriods.Count, schoolDay.Break3);
            timePeriods[timePeriods.Count - 1].Should().Be(schoolDay.Break3);
        }
Beispiel #2
0
        public void AddTimeRangeTest()
        {
            var schoolDay = new SchoolDay();
            var chain     = new TimePeriodChain(schoolDay);

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

            chain.Add(range);
            chain.Last.Should().Be(range);
        }
Beispiel #3
0
        public void ContainsPeriodTest()
        {
            var schoolDay = new SchoolDay();
            var chain     = new TimePeriodChain(schoolDay);

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

            chain.Contains(timeRange).Should().Be.False();
            chain.ContainsPeriod(timeRange).Should().Be.True();
        }
        public void IndexTest() {
            var schoolDay = new SchoolDay();

            schoolDay[0].Should().Be(schoolDay.Lesson1);
            schoolDay[1].Should().Be(schoolDay.Break1);
            schoolDay[2].Should().Be(schoolDay.Lesson2);
            schoolDay[3].Should().Be(schoolDay.Break2);
            schoolDay[4].Should().Be(schoolDay.Lesson3);
            schoolDay[5].Should().Be(schoolDay.Break3);
            schoolDay[6].Should().Be(schoolDay.Lesson4);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        public void RemoveTest()
        {
            var now         = ClockProxy.Clock.Now;
            var schoolDay   = new SchoolDay(now);
            var 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));
        }
Beispiel #7
0
        public void IndexTest()
        {
            var schoolDay = new SchoolDay();

            schoolDay[0].Should().Be(schoolDay.Lesson1);
            schoolDay[1].Should().Be(schoolDay.Break1);
            schoolDay[2].Should().Be(schoolDay.Lesson2);
            schoolDay[3].Should().Be(schoolDay.Break2);
            schoolDay[4].Should().Be(schoolDay.Lesson3);
            schoolDay[5].Should().Be(schoolDay.Break3);
            schoolDay[6].Should().Be(schoolDay.Lesson4);
        }
Beispiel #8
0
        public void StartMoveTest()
        {
            var now         = ClockProxy.Clock.Now;
            var schoolDay   = new SchoolDay(now);
            var 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 ItemIndexTest() {
            var timePeriods = new TimePeriodCollection();
            var 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 CopyConstructorTest() {
            var schoolDay = new SchoolDay();
            var copyChain = new TimePeriodChain(schoolDay);

            copyChain.Count.Should().Be(schoolDay.Count);
            copyChain.HasStart.Should().Be(schoolDay.HasStart);
            copyChain.HasEnd.Should().Be(schoolDay.HasEnd);
            copyChain.IsReadOnly.Should().Be(schoolDay.IsReadOnly);

            copyChain.Start.Should().Be(schoolDay.Start);
            copyChain.End.Should().Be(schoolDay.End);
            copyChain.Duration.Should().Be(schoolDay.Duration);
        }
Beispiel #11
0
        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);
        }
Beispiel #12
0
        public void CopyConstructorTest()
        {
            var schoolDay = new SchoolDay();
            var copyChain = new TimePeriodChain(schoolDay);

            copyChain.Count.Should().Be(schoolDay.Count);
            copyChain.HasStart.Should().Be(schoolDay.HasStart);
            copyChain.HasEnd.Should().Be(schoolDay.HasEnd);
            copyChain.IsReadOnly.Should().Be(schoolDay.IsReadOnly);

            copyChain.Start.Should().Be(schoolDay.Start);
            copyChain.End.Should().Be(schoolDay.End);
            copyChain.Duration.Should().Be(schoolDay.Duration);
        }
Beispiel #13
0
        public void ClearTest()
        {
            var 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);
        }
Beispiel #14
0
        public void AddAllTest()
        {
            var now         = ClockProxy.Clock.Now;
            var schoolDay   = new SchoolDay(now);
            var timePeriods = new TimePeriodCollection();

            timePeriods.Count.Should().Be(0);

            timePeriods.AddAll(schoolDay);
            timePeriods.Count.Should().Be(schoolDay.Count);

            timePeriods.Clear();
            timePeriods.Count.Should().Be(0);
        }
Beispiel #15
0
        protected void btnTerm_Click(object sender, EventArgs e)
        {
            List <Student>   schoolStudents = new List <Student>();
            Term             selectedTerm   = null;
            List <SchoolDay> schoolDays     = new List <SchoolDay>();

            using (SqlConnection connection = new SqlConnection(LSKYCommon.dbConnectionString_SchoolLogic))
            {
                int selectedTermID = -1;
                if (int.TryParse(drpTerm.SelectedValue, out selectedTermID))
                {
                    selectedTerm = Term.loadThisTerm(connection, selectedTermID);
                    if (selectedTerm != null)
                    {
                        Track selectedTrack = Track.loadThisTrack(connection, selectedTerm.trackID);

                        // Load school days for this school / track
                        schoolDays = SchoolDay.loadDaysFromThisTrack(connection, selectedTrack);

                        // Load students from the track
                        schoolStudents = Student.loadStudentsFromThisTrack(connection, selectedTrack.ID);

                        // Load timetables for the students that were loaded
                        foreach (Student student in schoolStudents)
                        {
                            student.TimeTable = TimeTableEntry.loadStudentTimeTable(connection, student, selectedTerm);
                        }
                    }
                }
            }

            tblCSVLink.Visible     = true;
            lnkCSVLink.NavigateUrl = "getCSV.aspx?schoolid=" + selectedTerm.schoolID + "&trackid=" + selectedTerm.trackID + "&termid=" + selectedTerm.ID;

            tblStudents.Rows.Clear();
            tblStudents.Visible = true;
            tblStudents.Rows.Add(generateStudentTableHeader(schoolDays));

            foreach (Student student in schoolStudents)
            {
                tblStudents.Rows.Add(generateStudentRow(student, schoolDays));
            }

            // Load the days from the specified track

            // Load all students

            // For each day, determine what their classes are
        }
Beispiel #16
0
        /// <summary>
        /// Получает из тегов h3 и table день недели и уроки в нем
        /// </summary>
        /// <param name="element">Тег table с днем недели</param>
        /// <returns>Объект SchoolDay для данного дня недели</returns>
        private SchoolDay GetSchoolDayOfClass(IElement element)
        {
            var dayOfWeekName = element.PreviousSibling;
            var schoolDay     = new SchoolDay(dayOfWeekName.TextContent);

            foreach (var item in element.GetElementsByTagName("tr"))
            {
                if (IsLessonOfClass(item))
                {
                    schoolDay.AddLesson(GetLessonOfClass(item));
                }
            }

            return(schoolDay);
        }
Beispiel #17
0
        public void ItemIndexTest()
        {
            var timePeriods = new TimePeriodCollection();
            var 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);
        }
Beispiel #18
0
        public void ContainsPeriodTest()
        {
            var now         = ClockProxy.Clock.Now;
            var schoolDay   = new SchoolDay(now);
            var timePeriods = new TimePeriodCollection(schoolDay);

            var 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));
        }
Beispiel #19
0
        public void StartMoveTest()
        {
            var now       = ClockProxy.Clock.Now;
            var schoolDay = new SchoolDay(now);

            schoolDay.Start.Should().Be(now);

            schoolDay.Start = now.AddHours(0);
            schoolDay.Start.Should().Be(now);

            schoolDay.Start = now.AddHours(1);
            schoolDay.Start.Should().Be(now.AddHours(1));

            schoolDay.Start = now.AddHours(-1);
            schoolDay.Start.Should().Be(now.AddHours(-1));
        }
Beispiel #20
0
        public void EndMoveTest()
        {
            var schoolDay   = new SchoolDay();
            var timePeriods = new TimePeriodCollection(schoolDay);

            var end = schoolDay.End;

            timePeriods.End = end.AddHours(0);
            timePeriods.End.Should().Be(end);

            timePeriods.End = end.AddHours(1);
            timePeriods.End.Should().Be(end.AddHours(1));

            timePeriods.End = end.AddHours(-1);
            timePeriods.End.Should().Be(end.AddHours(-1));
        }
Beispiel #21
0
        public void IsSamePeriodTest()
        {
            var       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));
        }
Beispiel #22
0
        public void IsSamePeriodTest()
        {
            var now         = ClockProxy.Clock.Now;
            var schoolDay   = new SchoolDay(now);
            var 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));
        }
Beispiel #23
0
        public void CopyToTest()
        {
            var now         = ClockProxy.Clock.Now;
            var schoolDay   = new SchoolDay(now);
            var timePeriods = new TimePeriodCollection(schoolDay);

            var array = new ITimePeriod[schoolDay.Count];

            timePeriods.CopyTo(array, 0);

            array[0].Should().Be(schoolDay.Lesson1);
            array[1].Should().Be(schoolDay.Break1);
            array[2].Should().Be(schoolDay.Lesson2);
            array[3].Should().Be(schoolDay.Break2);
            array[4].Should().Be(schoolDay.Lesson3);
            array[5].Should().Be(schoolDay.Break3);
            array[6].Should().Be(schoolDay.Lesson4);
        }
Beispiel #24
0
        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);
        }
Beispiel #25
0
        public void EndMoveTest()
        {
            var now       = ClockProxy.Clock.Now;
            var schoolDay = new SchoolDay(now);

            var end = schoolDay.End;

            schoolDay.End.Should().Be(end);

            schoolDay.End = end.AddHours(0);
            schoolDay.End.Should().Be(end);

            schoolDay.End = end.AddHours(1);
            schoolDay.End.Should().Be(end.AddHours(1));

            schoolDay.End = end.AddHours(-1);
            schoolDay.End.Should().Be(end.AddHours(-1));
        }
Beispiel #26
0
        public void AddTest()
        {
            var schoolDay = new SchoolDay();

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

            schoolDay.Add(shortBreak);

            schoolDay.Count.Should().Be(count + 1);
            schoolDay.Last.Should().Be(shortBreak);
            schoolDay.End.Should().Be(end.Add(shortBreak.Duration));

            shortBreak.Start.Should().Be(end);
            shortBreak.End.Should().Be(schoolDay.End);
            shortBreak.Duration.Should().Be(ShortBreak.ShortBreakDuration);
        }
Beispiel #27
0
        public void MoveTest()
        {
            var now         = ClockProxy.Clock.Now;
            var schoolDay   = new SchoolDay(now);
            var timePeriods = new TimePeriodCollection(schoolDay);

            var startDate     = schoolDay.Start;
            var endDate       = schoolDay.End;
            var startDuration = timePeriods.Duration;

            var duration = DurationUtil.Hour;

            timePeriods.Move(duration);

            timePeriods.Start.Should().Be(startDate.Add(duration));
            timePeriods.End.Should().Be(endDate.Add(duration));
            timePeriods.Duration.Should().Be(startDuration);
        }
Beispiel #28
0
        public void SortByEndTest()
        {
            DateTime             now         = ClockProxy.Clock.Now;
            SchoolDay            schoolDay   = new SchoolDay(now);
            TimePeriodCollection timePeriods = new TimePeriodCollection();

            timePeriods.AddAll(schoolDay);

            timePeriods.SortByEnd();

            timePeriods[0].Should().Be(schoolDay.Lesson4);
            timePeriods[1].Should().Be(schoolDay.Break3);
            timePeriods[2].Should().Be(schoolDay.Lesson3);
            timePeriods[3].Should().Be(schoolDay.Break2);
            timePeriods[4].Should().Be(schoolDay.Lesson2);
            timePeriods[5].Should().Be(schoolDay.Break1);
            timePeriods[6].Should().Be(schoolDay.Lesson1);
        }
Beispiel #29
0
        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));
        }
Beispiel #30
0
        public void InsertTest()
        {
            var 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);
        }
Beispiel #31
0
        public void RemoveAtTest()
        {
            var 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));
        }
Beispiel #32
0
        public void OverlapsWithTest()
        {
            SchoolDay schoolDay = new SchoolDay();
            TimeSpan  offset    = DurationUtil.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));
        }
Beispiel #33
0
        public void GetRelationTest()
        {
            var schoolDay = new SchoolDay();
            var offset    = DurationUtil.Second;
            var 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 RemoveAtTest() {
            var 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));
        }
        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);
        }
        public void StartMoveTest() {
            var now = ClockProxy.Clock.Now;
            var schoolDay = new SchoolDay(now);
            var 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 FirstTest() {
     var schoolDay = new SchoolDay();
     schoolDay.First.Should().Be(schoolDay.Lesson1);
 }
        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 MoveTest() {
            var now = ClockProxy.Clock.Now;
            var schoolDay = new SchoolDay(now);
            var timePeriods = new TimePeriodCollection(schoolDay);

            var startDate = schoolDay.Start;
            var endDate = schoolDay.End;
            var startDuration = timePeriods.Duration;

            var duration = DurationUtil.Hour;
            timePeriods.Move(duration);

            timePeriods.Start.Should().Be(startDate.Add(duration));
            timePeriods.End.Should().Be(endDate.Add(duration));
            timePeriods.Duration.Should().Be(startDuration);
        }
        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);
        }
        public void SortByStartTest() {
            var schoolDay = new SchoolDay();
            var timePeriods = new TimePeriodCollection
                              {
                                  schoolDay.Lesson4,
                                  schoolDay.Break3,
                                  schoolDay.Lesson3,
                                  schoolDay.Break2,
                                  schoolDay.Lesson2,
                                  schoolDay.Break1,
                                  schoolDay.Lesson1
                              };

            timePeriods.SortByStart();

            timePeriods[0].Should().Be(schoolDay.Lesson1);
            timePeriods[1].Should().Be(schoolDay.Break1);
            timePeriods[2].Should().Be(schoolDay.Lesson2);
            timePeriods[3].Should().Be(schoolDay.Break2);
            timePeriods[4].Should().Be(schoolDay.Lesson3);
            timePeriods[5].Should().Be(schoolDay.Break3);
            timePeriods[6].Should().Be(schoolDay.Lesson4);
        }
        public void InsertTest() {
            var 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 ClearTest() {
            var 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 InsertTest() {
            var now = ClockProxy.Clock.Now;
            var schoolDay = new SchoolDay(now);
            var timePeriods = new TimePeriodCollection();
            timePeriods.Count.Should().Be(0);

            timePeriods.Add(schoolDay.Lesson1);
            timePeriods.Count.Should().Be(1);
            timePeriods.Add(schoolDay.Lesson3);
            timePeriods.Count.Should().Be(2);
            timePeriods.Add(schoolDay.Lesson4);
            timePeriods.Count.Should().Be(3);

            // between
            timePeriods[1].Should().Be(schoolDay.Lesson3);
            timePeriods.Insert(1, schoolDay.Lesson2);
            timePeriods[1].Should().Be(schoolDay.Lesson2);

            // first
            timePeriods[0].Should().Be(schoolDay.Lesson1);
            timePeriods.Insert(0, schoolDay.Break1);
            timePeriods[0].Should().Be(schoolDay.Break1);

            // last
            timePeriods[timePeriods.Count - 1].Should().Be(schoolDay.Lesson4);
            timePeriods.Insert(timePeriods.Count, schoolDay.Break3);
            timePeriods[timePeriods.Count - 1].Should().Be(schoolDay.Break3);
        }
 public void LastTest() {
     var schoolDay = new SchoolDay();
     schoolDay.Last.Should().Be(schoolDay.Lesson4);
 }
        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));
        }
        public void GetRelationTest() {
            var schoolDay = new SchoolDay();
            var offset = DurationUtil.Second;
            var 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 OverlapsWithTest() {
            SchoolDay schoolDay = new SchoolDay();
            TimeSpan offset = DurationUtil.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 IndexOfTest() {
            var now = ClockProxy.Clock.Now;
            var schoolDay = new SchoolDay(now);
            var timePeriods = new TimePeriodCollection();

            timePeriods.IndexOf(new TimeRange()).Should().Be(-1);
            timePeriods.IndexOf(new TimeBlock()).Should().Be(-1);

            timePeriods.AddAll(schoolDay);

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

            timePeriods.Remove(schoolDay.Lesson1);
            timePeriods.IndexOf(schoolDay.Lesson1).Should().Be(-1);
            timePeriods.IndexOf(schoolDay.Break1).Should().Be(0);
        }
        public void IsSamePeriodTest() {
            var now = ClockProxy.Clock.Now;
            var schoolDay = new SchoolDay(now);
            var 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 CopyToTest() {
            var now = ClockProxy.Clock.Now;
            var schoolDay = new SchoolDay(now);
            var timePeriods = new TimePeriodCollection(schoolDay);

            var array = new ITimePeriod[schoolDay.Count];
            timePeriods.CopyTo(array, 0);

            array[0].Should().Be(schoolDay.Lesson1);
            array[1].Should().Be(schoolDay.Break1);
            array[2].Should().Be(schoolDay.Lesson2);
            array[3].Should().Be(schoolDay.Break2);
            array[4].Should().Be(schoolDay.Lesson3);
            array[5].Should().Be(schoolDay.Break3);
            array[6].Should().Be(schoolDay.Lesson4);
        }
        public void RemoveTest() {
            var now = ClockProxy.Clock.Now;
            var schoolDay = new SchoolDay(now);
            var 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 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 RemoveAtTest() {
            var now = ClockProxy.Clock.Now;
            var schoolDay = new SchoolDay(now);
            var timePeriods = new TimePeriodCollection(schoolDay);

            // inside
            timePeriods[2].Should().Be(schoolDay.Lesson2);
            timePeriods.RemoveAt(2);
            timePeriods[2].Should().Be(schoolDay.Break2);

            // first
            timePeriods[0].Should().Be(schoolDay.Lesson1);
            timePeriods.RemoveAt(0);
            timePeriods[0].Should().Be(schoolDay.Break1);

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

            var 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 IsSamePeriodTest() {
            var 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 SortByEndTest() {
            DateTime now = ClockProxy.Clock.Now;
            SchoolDay schoolDay = new SchoolDay(now);
            TimePeriodCollection timePeriods = new TimePeriodCollection();

            timePeriods.AddAll(schoolDay);

            timePeriods.SortByEnd();

            timePeriods[0].Should().Be(schoolDay.Lesson4);
            timePeriods[1].Should().Be(schoolDay.Break3);
            timePeriods[2].Should().Be(schoolDay.Lesson3);
            timePeriods[3].Should().Be(schoolDay.Break2);
            timePeriods[4].Should().Be(schoolDay.Lesson2);
            timePeriods[5].Should().Be(schoolDay.Break1);
            timePeriods[6].Should().Be(schoolDay.Lesson1);
        }
        public void AddAllTest() {
            var now = ClockProxy.Clock.Now;
            var schoolDay = new SchoolDay(now);
            var timePeriods = new TimePeriodCollection();

            timePeriods.Count.Should().Be(0);

            timePeriods.AddAll(schoolDay);
            timePeriods.Count.Should().Be(schoolDay.Count);

            timePeriods.Clear();
            timePeriods.Count.Should().Be(0);
        }
        public void GetGapTest() {
            var now = ClockProxy.Clock.Now;
            var schoolDay = new SchoolDay(now);

            var gapCalculator = new TimeGapCalculator<TimeRange>();

            var excludePeriods = new TimePeriodCollection();
            excludePeriods.AddAll(schoolDay);

            gapCalculator.GetGaps(excludePeriods).Count.Should().Be(0);
            gapCalculator.GetGaps(excludePeriods, schoolDay).Count.Should().Be(0);

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

            var gaps2 = gapCalculator.GetGaps(excludePeriods);
            gaps2.Count.Should().Be(3);
            gaps2[0].IsSamePeriod(schoolDay.Break1).Should().Be.True();
            gaps2[1].IsSamePeriod(schoolDay.Break2).Should().Be.True();
            gaps2[2].IsSamePeriod(schoolDay.Break3).Should().Be.True();

            var testRange3 = new TimeRange(schoolDay.Lesson1.Start, schoolDay.Lesson4.End);
            var gaps3 = gapCalculator.GetGaps(excludePeriods, testRange3);
            gaps3.Count.Should().Be(3);
            gaps3[0].IsSamePeriod(schoolDay.Break1).Should().Be.True();
            gaps3[1].IsSamePeriod(schoolDay.Break2).Should().Be.True();
            gaps3[2].IsSamePeriod(schoolDay.Break3).Should().Be.True();

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

            gaps4.Count.Should().Be(5);
            gaps4[0].IsSamePeriod(new TimeRange(testRange4.Start, schoolDay.Start)).Should().Be.True();
            gaps4[1].IsSamePeriod(schoolDay.Break1).Should().Be.True();
            gaps4[2].IsSamePeriod(schoolDay.Break2).Should().Be.True();
            gaps4[3].IsSamePeriod(schoolDay.Break3).Should().Be.True();
            gaps4[4].IsSamePeriod(new TimeRange(testRange4.End, schoolDay.End)).Should().Be.True();


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

            gaps8.Count.Should().Be(0);


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

            gaps9.Count.Should().Be(2);
            gaps9[0].Duration.Should().Be(TimeSpan.FromTicks(1));
            gaps9[1].Duration.Should().Be(TimeSpan.FromTicks(1));
        }
        public void EndMoveTest() {
            var schoolDay = new SchoolDay();
            var timePeriods = new TimePeriodCollection(schoolDay);

            var end = schoolDay.End;

            timePeriods.End = end.AddHours(0);
            timePeriods.End.Should().Be(end);

            timePeriods.End = end.AddHours(1);
            timePeriods.End.Should().Be(end.AddHours(1));

            timePeriods.End = end.AddHours(-1);
            timePeriods.End.Should().Be(end.AddHours(-1));
        }