Exemple #1
0
        public void TestCreateTerms()
        {
            SqlCalendar sql = new SqlCalendar();
            IEnumerable <ClassCalendar> querycal =
                from elem in sql.CalendarList()
                where elem.Month == 2
                select elem;
            ClassCalendar calendar = querycal.First();

            sql.CreateTerms("('08:00:00','12:00:00','2000-2-1',3,1,100,1),('13:00:00','15:00:00','2000-2-2',4,2,200,2)");
            ClassGenerateCalendar.ShareCalendar(calendar, sql);

            List <ClassTerm>        list  = sql.ListOfTerms();
            IEnumerable <ClassTerm> query =
                from elem in list
                where elem.TermId == 3 && elem.CalendarDay.CalendarDayId == 1 && elem.Doctor.Doctor_id == 1 && elem.StartTime.CompareTo(new TimeSpan(8, 0, 0)) == 0 && elem.EndTime.CompareTo(new TimeSpan(12, 0, 0)) == 0
                select elem;

            Assert.Single(query);

            query =
                from elem in list
                where elem.TermId == 4 && elem.CalendarDay.CalendarDayId == 2 && elem.Doctor.Doctor_id == 2 && elem.StartTime.CompareTo(new TimeSpan(13, 0, 0)) == 0 && elem.EndTime.CompareTo(new TimeSpan(15, 0, 0)) == 0
                select elem;

            Assert.Single(query);

            querycal =
                from elem in sql.CalendarList()
                where elem.Month == 2
                select elem;

            calendar = querycal.First();
            Assert.Equal(2, calendar.Status.StatusId);
        }