예제 #1
0
        public async Task TeacherGroupTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage     = new CourseStorage(connection, transaction);
            dictionaryStorage = new DictionaryStorage(connection, transaction);
            userStorage       = new UserStorage(connection, transaction);
            groupStorage      = new GroupStorage(connection, transaction);

            try
            {
                await Setup();
                await TestSelects();

                foreach (TeacherGroup teacherGroupToDelete in listTeacherGroup)
                {
                    await TestEntityDelete(teacherGroupToDelete);
                }

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
예제 #2
0
        public async Task CourseProgramSkillTest()
        {
            IDbConnection connection = new SqlConnection(DBConnection.connString);

            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage = new CourseStorage(connection, transaction);
            try
            {
                await Setup();
                await TestSelects();

                foreach (CourseProgramSkill CourseProgramSkillToDelete in listCourseProgramSkill)
                {
                    await CourseProgramSkillTestDelete(CourseProgramSkillToDelete);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                transaction.Rollback();
            }
        }
예제 #3
0
        public void StudentGroupTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage     = new CourseStorage(connection, transaction);
            dictionaryStorage = new DictionaryStorage(connection, transaction);
            userStorage       = new UserStorage(connection, transaction);
            groupStorage      = new GroupStorage(connection, transaction);

            try
            {
                Setup();
                TestSelects();
                foreach (StudentGroup studentGroupToDelete in listStudentGroup)
                {
                    TestEntityDelete(studentGroupToDelete);
                }
                ClearTest();

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
예제 #4
0
        public async Task LessonTopicTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage = new CourseStorage(connection, transaction);
            groupStorage  = new GroupStorage(connection, transaction);
            lessonStorage = new LessonStorage(connection, transaction);

            try
            {
                await Setup();
                await TestSelects();

                foreach (LessonTopic lessonTopicToDelete in listLessonTopic)
                {
                    await TestEntityDelete(lessonTopicToDelete);
                }
            }
            catch
            {
                throw new Exception();
            }
            finally
            {
                transaction.Rollback();
            }
        }
예제 #5
0
        public async Task JournalTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage     = new CourseStorage(connection, transaction);
            groupStorage      = new GroupStorage(connection, transaction);
            dictionaryStorage = new DictionaryStorage(connection, transaction);
            userStorage       = new UserStorage(connection, transaction);
            lessonStorage     = new LessonStorage(connection, transaction);

            try
            {
                await Setup();
                await TestSelects();
                await TestUpdate();

                foreach (Journal journalToDelete in listJournal)
                {
                    await TestEntityDelete(journalToDelete);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                transaction.Rollback();
            }
        }
예제 #6
0
        public void GeneralTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage = new CourseStorage(connection, transaction);

            try
            {
                Setup();
                TestSelects();
                TestUpdate();

                foreach (ThemeDetails ThemeDetailsToDelete in themeDetailsList)
                {
                    TestEntityDelete(ThemeDetailsToDelete);
                }

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new System.Exception();
            }
        }
예제 #7
0
        public void TimeTableTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            groupStorage  = new GroupStorage(connection, transaction);
            lessonStorage = new LessonStorage(connection, transaction);
            courseStorage = new CourseStorage(connection, transaction);

            try
            {
                Setup();
                TestSelects();
                TestUpdate();

                foreach (TimeTable timeTableToDelete in listTimetable)
                {
                    TestEntityDelete(timeTableToDelete);
                }

                ClearAllMocks();

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
예제 #8
0
        public LessonController(IConfiguration Configuration)
        {
            string dbCon = Configuration.GetConnectionString("DefaultConnection");

            lessonStorage = new LessonStorage(dbCon);
            groupStorage  = new GroupStorage(dbCon);
            courseStorage = new CourseStorage(dbCon);
        }
예제 #9
0
        }// add check for authorization

        public void Delete(Course course)
        {
            if (CheckOwnership(course.Id) != OwnershipType.None)
            {
                CourseStorage.Delete(course);
            }
            else
            {
                throw new AccessViolationException();
            }
        }// add check for authorization
예제 #10
0
 public SearchResultList GetSearchResults(string searchString, SearchMode type, ref SearchResultList resultList)
 {
     try
     {
         SearchResultList result = CourseStorage.Search(searchString, type, ref resultList);
         return(result);
     }
     catch (KeyNotFoundException)
     {
         return(null);
     }
 }
예제 #11
0
 public Course Add(Course course)
 {
     if (CheckOwnership(course.Id) != OwnershipType.None)
     {
         if (course.Title == null || course.Author == null)
         {
             return(null);
         }
         Course result = CourseStorage.Add(course);
         return(result);
     }
     else
     {
         throw new AccessViolationException();
     }
 }// add check for authorization
예제 #12
0
        public void User_SkillTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            dictionaryStorage = new DictionaryStorage(connection, transaction);

            userStorage = new UserStorage(connection, transaction);

            courseStorage = new CourseStorage(connection, transaction);



            try
            {
                Setup();

                TestSelects();

                TestDelete();

                //TestUpdate();



                //foreach (Journal journalToDelete in listJournal)

                //{

                //    TestEntityDelete(journalToDelete);

                //}



                ClearShit();

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new Exception();
            }
        }
예제 #13
0
 public Course GetById(string id)
 {
     if (CheckOwnership(id) != OwnershipType.None)
     {
         try
         {
             return(CourseStorage.GetCourse(id));
         }
         catch (ArgumentOutOfRangeException)
         {
             return(null);
         }
     }
     else
     {
         throw new AccessViolationException();
     }
 }
예제 #14
0
        }// add check for authorization

        public Course Edit(Course course)// add check for authorization
        {
            if (CheckOwnership(course.Id) != OwnershipType.None)
            {
                try
                {
                    Course result = CourseStorage.Edit(course);
                    return(result);
                }
                catch (ArgumentOutOfRangeException)
                {
                    return(null);
                }
            }
            else
            {
                throw new AccessViolationException();
            }
        }
예제 #15
0
 public CourseInfo GetCourseInfo(string id)
 {
     try
     {
         Course result = GetById(id);
         if (result != null)
         {
             return(CourseStorage.GetCourseInfo(result));
         }
         else
         {
             return(null);
         }
     }
     catch (ArgumentOutOfRangeException)
     {
         return(null);
     }
 }
예제 #16
0
        public void ProgramDetailsTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage = new CourseStorage(connection, transaction);

            try
            {
                Setup();
                TestSelects();
                TestUpdate();
                TestDeleteProgramDetails(listProgramDetails);

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
                throw new System.Exception();
            }
        }
예제 #17
0
        public async Task GeneralTest()
        {
            IDbConnection connection = new SqlConnection(DBConnection.connString);

            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            storage = new CourseStorage(connection, transaction);

            try
            {
                await CreateCourseProgram();
                await UpdateCourseProgram();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                transaction.Rollback();
            }
        }
예제 #18
0
파일: CourseTests.cs 프로젝트: evsig/DevEdu
        public async Task CourseTest()
        {
            using IDbConnection connection = new SqlConnection(DBConnection.connString);
            connection.Open();
            IDbTransaction transaction = connection.BeginTransaction();

            courseStorage = new CourseStorage(connection, transaction);

            try
            {
                await Setup();
                await TestSelects();
                await TestUpdate();
                await TestDeleteCourse(listCourse);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                transaction.Rollback();
            }
        }
예제 #19
0
        public CourseController(IConfiguration Configuration)
        {
            string dbCon = Configuration.GetConnectionString("DefaultConnection");

            courseStorage = new CourseStorage(dbCon);
        }