Exemple #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);
        }
Exemple #2
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);
        }
Exemple #3
0
        public void TestCalendarList()
        {
            SqlCalendar sql = new SqlCalendar();

            Assert.Equal(3, sql.CalendarList().Count);

            IEnumerable <ClassCalendar> query =
                from elem in sql.CalendarList()
                where elem.Year == 2000 && elem.Month == 2 && elem.CalendarId == 1 && elem.Status.StatusId == 1
                select elem;

            Assert.Single(query);

            query =
                from elem in sql.CalendarList()
                where elem.Year == 2000 && elem.Month == 3 && elem.CalendarId == 2 && elem.Status.StatusId == 3
                select elem;

            Assert.Single(query);

            query =
                from elem in sql.CalendarList()
                where elem.Year == 2000 && elem.Month == 4 && elem.CalendarId == 3 && elem.Status.StatusId == 1
                select elem;

            Assert.Single(query);
        }
Exemple #4
0
        public void TestTermLisTSelectedDoctor()
        {
            SqlCalendar sql = new SqlCalendar();

            IEnumerable <ClassTerm> query =
                from elem in sql.TermLisTSelectedDoctor(1, 1)
                select elem;

            Assert.Single(query);
        }
Exemple #5
0
        public void TestDoctorList(bool active, int doctorId, string name, string surname, int officeNumber)
        {
            SqlCalendar sql = new SqlCalendar();
            IEnumerable <ClassDoctor> query =
                from elem in sql.DoctorList()
                where elem.Active == active && elem.Doctor_id == doctorId && elem.Name == name && elem.Surname == surname && elem.OfficeNumber == officeNumber
                select elem;

            Assert.Single(query);
        }
Exemple #6
0
        public void TestListFixedTermsForSpecifiedDoctor(int doctorId, int day)
        {
            SqlCalendar sql = new SqlCalendar();

            IEnumerable <ClassFixedTerms> query =
                from elem in sql.ListFixedTermsForSpecifiedDoctor(doctorId)
                where elem.Day == day
                select elem;

            Assert.Single(query);
        }
Exemple #7
0
        public void TestListOfCalendarDoctor(int calendarDoctorId, int calendarId, int doctorId, int statusId)
        {
            SqlCalendar sql = new SqlCalendar();

            IEnumerable <ClassCalendarDoctor> query =
                from elem in sql.ListOfCalendarDoctor(calendarId)
                where elem.CalendarDoctorId == calendarDoctorId && elem.Doctor.Doctor_id == doctorId && elem.Status.StatusId == statusId
                select elem;

            Assert.Single(query);
        }
Exemple #8
0
        public void TestStatusList(int id, string status)
        {
            SqlCalendar sql = new SqlCalendar();

            IEnumerable <ClassStatus> query =
                from elem in sql.StatusList()
                where elem.StatusId == id && elem.Status == status
                select elem;

            Assert.Single(query);
        }
Exemple #9
0
        public void TestListOfTerms(int termId, int calendarDayId, int doctorId, int calendarDoctorId, int officeNumber)
        {
            SqlCalendar sql = new SqlCalendar();

            IEnumerable <ClassTerm> query =
                from elem in sql.ListOfTerms()
                where elem.TermId == termId && elem.CalendarDay.CalendarDayId == calendarDayId && elem.Doctor.Doctor_id == doctorId && elem.CalendarDoctor.CalendarDoctorId == calendarDoctorId && elem.Office.OfficeNumber == officeNumber
                select elem;

            Assert.Single(query);
        }
Exemple #10
0
        public void TestTermsForSpecifiedYearAndMonth(int termId, int calendarDayId, int calendarDoctorId, int officeNumber, int year, int month)
        {
            SqlCalendar sql = new SqlCalendar();

            IEnumerable <ClassTerm> query =
                from elem in sql.TermsForSpecifiedYearAndMonth(year, month)
                where elem.TermId == termId && elem.CalendarDay.CalendarDayId == calendarDayId && elem.CalendarDoctor.CalendarDoctorId == calendarDoctorId && elem.Office.OfficeNumber == officeNumber
                select elem;

            Assert.Single(query);
        }
Exemple #11
0
        public void TestUpdateCalendarStatus()
        {
            SqlCalendar sql = new SqlCalendar();

            sql.UpdateCalendarStatus(3, 3);

            IEnumerable <ClassCalendar> query =
                from elem in sql.CalendarList()
                where elem.Status.StatusId == 3 && elem.CalendarId == 3
                select elem;

            Assert.Single(query);
        }
Exemple #12
0
        public void TestDeleteTerm()
        {
            SqlCalendar sql = new SqlCalendar();

            sql.DeleteTerm(1);

            IEnumerable <ClassTerm> query =
                from elem in sql.ListOfTerms()
                where elem.TermId == 1
                select elem;

            Assert.Empty(query);
        }
Exemple #13
0
        public void TestDeleteCalendarDay()
        {
            SqlCalendar sql = new SqlCalendar();

            sql.DeleteCalendarDay(1);

            IEnumerable <ClassCalendarDay> query =
                from elem in sql.ListOfCalendarDays(1)
                where elem.CalendarDayId == 1
                select elem;

            Assert.Empty(query);
        }
Exemple #14
0
        public void TestUpdateOffice()
        {
            SqlCalendar sql = new SqlCalendar();

            sql.UpdateOffice(1, 200);

            IEnumerable <ClassTerm> query =
                from elem in sql.ListOfTerms()
                where elem.TermId == 1 && elem.Office.OfficeNumber == 200
                select elem;

            Assert.Single(query);
        }
Exemple #15
0
        public void TestCreateCalendarDoctor()
        {
            int         id       = 3;
            SqlCalendar sql      = new SqlCalendar();
            int         expected = sql.ListOfCalendarDoctor(id).Count + 1;

            sql.CreateCalendarDoctor(1, 3);
            int actual = sql.ListOfCalendarDoctor(id).Count;

            IEnumerable <ClassCalendarDoctor> query =
                from elem in sql.ListOfCalendarDoctor(id)
                where elem.Doctor.Doctor_id == 1 && elem.Status.StatusId == 6
                select elem;

            Assert.Single(query);
        }
Exemple #16
0
        public void TestListOfCalendarDays()
        {
            SqlCalendar sql = new SqlCalendar();

            IEnumerable <ClassCalendarDay> query =
                from elem in sql.ListOfCalendarDays(1)
                where elem.CalendarDayId == 1 && 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(1)
                where elem.CalendarDayId == 2 && 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);
        }
Exemple #17
0
        public void TestCreateCalendar()
        {
            SqlCalendar sql = new SqlCalendar();

            int expected = sql.CalendarList().Count + 1;

            sql.CreateCalendar(2000, 1);
            int actual = sql.CalendarList().Count;

            Assert.Equal(expected, actual);

            IEnumerable <ClassCalendar> query =
                from elem in sql.CalendarList()
                where elem.Year == 2000 && elem.Month == 1 && elem.Status.StatusId == 1
                select elem;

            Assert.Single(query);
        }
Exemple #18
0
        public void TestDeleteCalendarAndApropriateCalendarDays()
        {
            SqlCalendar sql = new SqlCalendar();

            sql.DeleteCalendarAndApropriateCalendarDays(1);

            IEnumerable <ClassCalendarDay> query =
                from elem in sql.ListOfCalendarDays(1)
                select elem;

            Assert.Empty(query);

            IEnumerable <ClassCalendar> query2 =
                from elem in sql.CalendarList()
                where elem.CalendarId == 1
                select elem;

            Assert.Empty(query2);
        }
Exemple #19
0
        public void TestGenerationOfCalendar()
        {
            SqlCalendar sql      = new SqlCalendar();
            List <int>  expected = ClassGenerateCalendar.WorkingDaysInMonth(2000, 1);

            ClassGenerateCalendar.GenerateCalendar(2000, 1, sql);

            List <ClassCalendar>        list  = sql.CalendarList();
            IEnumerable <ClassCalendar> query =
                from elem in list
                where elem.Year == 2000 && elem.Month == 1
                select elem;

            Assert.Single(query);
            int calendarId = (query.First()).CalendarId;
            List <ClassCalendarDay> actual = sql.ListOfCalendarDays(calendarId);

            for (int i = 0; i < expected.Count; i++)
            {
                Assert.Equal(expected[i], actual[i].Day);
            }
        }
Exemple #20
0
        public void TestSelectCalendarId(int year, int month, int expected)
        {
            SqlCalendar sql = new SqlCalendar();

            Assert.Equal(expected, sql.SelectCalendarId(year, month));
        }
Exemple #21
0
        public void TestSelectCalendarDayId(int Day, int Calendar_id, int expected)
        {
            SqlCalendar sql = new SqlCalendar();

            Assert.Equal(expected, sql.SelectCalendarDayId(Day, Calendar_id));
        }
Exemple #22
0
        public void TestSelectStatusId(EnumStatus enumstatus, int expected)
        {
            SqlCalendar sql = new SqlCalendar();

            Assert.Equal(expected, sql.SelectStatusId(enumstatus));
        }