示例#1
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);
        }
示例#2
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);
        }
示例#3
0
            public int CompareFieldValueTo(FieldIndex field, Solution other)
            {
                switch (field)
                {
                case FieldIndex.TimeAtUni:
                    return(TimeAtUni.CompareTo(other.TimeAtUni));

                case FieldIndex.TimeInClasses:
                    return(TimeInClasses.CompareTo(other.TimeInClasses));

                case FieldIndex.TimeInBreaks:
                    return(TimeInBreaks.CompareTo(other.TimeInBreaks));

                case FieldIndex.Days:
                    return(Days.CompareTo(other.Days));

                case FieldIndex.MinDayLength:
                    return(MinDayLength.CompareTo(other.MinDayLength));

                case FieldIndex.MaxDayLength:
                    return(MaxDayLength.CompareTo(other.MaxDayLength));

                case FieldIndex.AverageDayLength:
                    return(AverageDayLength.CompareTo(other.AverageDayLength));

                case FieldIndex.ShortBreak:
                    return(ShortBreak.CompareTo(other.ShortBreak));

                case FieldIndex.LongBreak:
                    return(LongBreak.CompareTo(other.LongBreak));

                case FieldIndex.AverageBreak:
                    return(AverageBreak.CompareTo(other.AverageBreak));

                case FieldIndex.NumberBreaks:
                    return(NumberBreaks.CompareTo(other.NumberBreaks));

                case FieldIndex.ShortBlock:
                    return(ShortBlock.CompareTo(other.ShortBlock));

                case FieldIndex.LongBlock:
                    return(LongBlock.CompareTo(other.LongBlock));

                case FieldIndex.AverageBlock:
                    return(AverageBlock.CompareTo(other.AverageBlock));

                case FieldIndex.NumberBlocks:
                    return(NumberBlocks.CompareTo(other.NumberBlocks));

                case FieldIndex.EarlyStart:
                    return(EarlyStart.CompareTo(other.EarlyStart));

                case FieldIndex.LateStart:
                    return(LateStart.CompareTo(other.LateStart));

                case FieldIndex.AverageStart:
                    return(AverageStart.CompareTo(other.AverageStart));

                case FieldIndex.EarlyEnd:
                    return(EarlyEnd.CompareTo(other.EarlyEnd));

                case FieldIndex.LateEnd:
                    return(LateEnd.CompareTo(other.LateEnd));

                case FieldIndex.AverageEnd:
                    return(AverageEnd.CompareTo(other.AverageEnd));

                default:
                    return(0);
                }
            }
示例#4
0
            /*public IComparable Field(int field)
             * {
             * switch (field)
             * {
             *  case 0:
             *      return (IComparable)TimeAtUni_;
             *  case 1:
             *      return (IComparable)TimeInClasses_;
             *  case 2:
             *      return (IComparable)TimeInBreaks_;
             *  case 3:
             *      return Days_;
             *  case 4:
             *      return (IComparable)MinDayLength_;
             *  case 5:
             *      return (IComparable)MaxDayLength_;
             *  case 6:
             *      return (IComparable)AverageDayLength_;
             *  case 7:
             *      return (IComparable)ShortBreak_;
             *  case 8:
             *      return (IComparable)LongBreak_;
             *  case 9:
             *      return (IComparable)AverageBreak_;
             *  case 10:
             *      return NumberBreaks_;
             *  case 11:
             *      return (IComparable)ShortBlock_;
             *  case 12:
             *      return (IComparable)LongBlock_;
             *  case 13:
             *      return (IComparable)AverageBlock_;
             *  case 14:
             *      return NumberBlocks_;
             *  case 15:
             *      return (IComparable)EarlyStart_;
             *  case 16:
             *      return (IComparable)LateStart_;
             *  case 17:
             *      return (IComparable)AverageStart_;
             *  case 18:
             *      return (IComparable)EarlyEnd_;
             *  case 19:
             *      return (IComparable)LateEnd_;
             *  case 20:
             *      return (IComparable)AverageEnd_;
             *  default:
             *      throw new Exception("Field index out of range.");
             * }
             * }*/

            public string FieldValueToString(FieldIndex field)
            {
                switch (field)
                {
                case FieldIndex.TimeAtUni:
                    return(TimeAtUni.ToString());

                case FieldIndex.TimeInClasses:
                    return(TimeInClasses.ToString());

                case FieldIndex.TimeInBreaks:
                    return(TimeInBreaks.ToString());

                case FieldIndex.Days:
                    return(Days.ToString());

                case FieldIndex.MinDayLength:
                    return(MinDayLength.ToString());

                case FieldIndex.MaxDayLength:
                    return(MaxDayLength.ToString());

                case FieldIndex.AverageDayLength:
                    return(AverageDayLength.ToString());

                case FieldIndex.ShortBreak:
                    return(ShortBreak.ToString());

                case FieldIndex.LongBreak:
                    return(LongBreak.ToString());

                case FieldIndex.AverageBreak:
                    return(AverageBreak.ToString());

                case FieldIndex.NumberBreaks:
                    return(NumberBreaks.ToString());

                case FieldIndex.ShortBlock:
                    return(ShortBlock.ToString());

                case FieldIndex.LongBlock:
                    return(LongBlock.ToString());

                case FieldIndex.AverageBlock:
                    return(AverageBlock.ToString());

                case FieldIndex.NumberBlocks:
                    return(NumberBlocks.ToString());

                case FieldIndex.EarlyStart:
                    return(EarlyStart.ToString());

                case FieldIndex.LateStart:
                    return(LateStart.ToString());

                case FieldIndex.AverageStart:
                    return(AverageStart.ToString());

                case FieldIndex.EarlyEnd:
                    return(EarlyEnd.ToString());

                case FieldIndex.LateEnd:
                    return(LateEnd.ToString());

                case FieldIndex.AverageEnd:
                    return(AverageEnd.ToString());

                default:
                    return("");
                }
            }
        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 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);
        }