Ejemplo n.º 1
0
        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.Equal <int>(schoolDay.Count, count - 1);
            Assert.NotEqual(schoolDay.First, removeItem);
            Assert.Equal <DateTime>(schoolDay.End, end);
            Assert.Equal <TimeSpan>(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.Equal <int>(schoolDay.Count, count - 1);
            Assert.NotEqual(schoolDay[1], removeItem);
            Assert.Equal(schoolDay.First, first);
            Assert.Equal <DateTime>(schoolDay.Start, start);
            Assert.Equal(schoolDay.Last, last);
            Assert.Equal <TimeSpan>(schoolDay.Duration, duration.Subtract(removeItem.Duration));

            // last
            count      = schoolDay.Count;
            start      = schoolDay.Start;
            duration   = schoolDay.Duration;
            removeItem = schoolDay.Last;
            schoolDay.Remove(removeItem);
            Assert.Equal <int>(schoolDay.Count, count - 1);
            Assert.NotEqual(schoolDay.Last, removeItem);
            Assert.Equal <DateTime>(schoolDay.Start, start);
            Assert.Equal <TimeSpan>(schoolDay.Duration, duration.Subtract(removeItem.Duration));
        }         // RemoveTest
Ejemplo n.º 2
0
        public void IndexOfTest()
        {
            SchoolDay schoolDay = new SchoolDay();

            Assert.Equal <int>(schoolDay.IndexOf(new TimeRange()), -1);
            Assert.Equal <int>(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 <int>(schoolDay.IndexOf(schoolDay.Lesson1), -1);
        }         // IndexOfTest
Ejemplo n.º 3
0
        public void ContainsTest()
        {
            SchoolDay schoolDay = new SchoolDay();

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

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

            schoolDay.Remove(schoolDay.Lesson1);
            Assert.False(schoolDay.Contains(schoolDay.Lesson1));
        }         // ContainsTest