Пример #1
0
        public void TestCreateCalendarDays()
        {
            SqlCalendar sql = new SqlCalendar();

            IEnumerable <ClassCalendar> querycal =
                from elem in sql.CalendarList()
                where elem.Month == 4
                select elem;
            ClassCalendar calendar = querycal.First();
            int           id       = calendar.CalendarId;

            sql.CreateCalendarDays("(1,'07:00:00','20:00:00'," + id + "),(2,'07:00:00','20:00:00'," + id + "),(3,'07:00:00','20:00:00'," + id + ")");

            IEnumerable <ClassCalendarDay> query =
                from elem in sql.ListOfCalendarDays(id)
                where elem.Day == 1 && elem.StartTime.CompareTo(new TimeSpan(7, 0, 0)) == 0 && elem.EndTime.CompareTo(new TimeSpan(20, 0, 0)) == 0
                select elem;

            Assert.Single(query);

            query =
                from elem in sql.ListOfCalendarDays(id)
                where elem.Day == 2 && elem.StartTime.CompareTo(new TimeSpan(7, 0, 0)) == 0 && elem.EndTime.CompareTo(new TimeSpan(20, 0, 0)) == 0
                select elem;

            Assert.Single(query);

            query =
                from elem in sql.ListOfCalendarDays(id)
                where elem.Day == 3 && elem.StartTime.CompareTo(new TimeSpan(7, 0, 0)) == 0 && elem.EndTime.CompareTo(new TimeSpan(20, 0, 0)) == 0
                select elem;

            Assert.Single(query);
        }