Example #1
0
 private void attach_Stages(Stage entity)
 {
     this.SendPropertyChanging();
     entity.Curriculum = this;
 }
Example #2
0
 private void detach_Stages(Stage entity)
 {
     this.SendPropertyChanging();
     entity.Curriculum = null;
 }
Example #3
0
 public void DeleteTheme()
 {
     Curriculum cur = new Curriculum() { Name = "Curriculum" };
     _Storage.AddCurriculum(cur);
     CurriculumAssignment as1 = new CurriculumAssignment() { Curriculum = cur, UserGroupRef = 1 };
     _Storage.AddCurriculumAssignment(as1);
     Stage st = new Stage() { Name = "Stage", Curriculum = cur };
     _Storage.AddStage(st);
     Theme theme = new Theme() { Name = "Theme", Stage = st, ThemeType = _Storage.GetThemeType(1) };
     int id = _Storage.AddTheme(theme);
     _Storage.DeleteTheme(id);
     Assert.AreEqual(null, _Storage.GetTheme(id));
     Assert.AreEqual(0, _Storage.GetThemeAssignmentsByThemeId(id).Count());
     try
     {
         _Storage.DeleteTheme(0);
         Assert.Fail();
     }
     catch (Exception)
     {
         Assert.True(true);
     }
 }
Example #4
0
 public void DeletingThemeWhenStageDeleted()
 {
     Curriculum cur = new Curriculum() { Name = "Curriculum" };
     _Storage.AddCurriculum(cur);
     CurriculumAssignment as1 = new CurriculumAssignment() { Curriculum = cur, UserGroupRef = 1 };
     _Storage.AddCurriculumAssignment(as1);
     Stage st = new Stage() { Name = "Stage", Curriculum = cur };
     var stageId = _Storage.AddStage(st);
     Theme theme = new Theme() { Name = "Theme", Stage = st, ThemeType = _Storage.GetThemeType(1) };
     int id = _Storage.AddTheme(theme);
     _Storage.DeleteStage(stageId);
     Assert.AreEqual(null, _Storage.GetTheme(id));
 }
Example #5
0
        public void GetThemesAvailableForUser()
        {
            Curriculum curr = new Curriculum() { Name = "Curriculum" };
            Curriculum curr1 = new Curriculum() { Name = "Curriculum1" };
            _Storage.AddCurriculum(curr);
            _Storage.AddCurriculum(curr1);

            DateTime dtStart = new DateTime(2011, 11, 11, 0, 0, 0);
            DateTime dtIn = new DateTime(2040, 11, 11, 0, 0, 0);
            DateTime dtOf = new DateTime(2011, 11, 12, 0, 0, 0);
            CurriculumAssignment as1 = new CurriculumAssignment() { Curriculum = curr, UserGroupRef = 1 };
            CurriculumAssignment as2 = new CurriculumAssignment() { Curriculum = curr1, UserGroupRef = 1 };
            _Storage.AddCurriculumAssignment(as1);
            _Storage.AddCurriculumAssignment(as2);

            Timeline tml = new Timeline() { CurriculumAssignment = as1, StartDate = dtStart, EndDate = dtIn };
            Timeline tml1 = new Timeline() { CurriculumAssignment = as2, StartDate = dtStart, EndDate = dtOf };
            _Storage.AddTimeline(tml);
            _Storage.AddTimeline(tml1);

            Stage st = new Stage() { Name = "Stage1", Curriculum = curr };
            Stage st1 = new Stage() { Name = "Stage2", Curriculum = curr1 };
            _Storage.AddStage(st);
            _Storage.AddStage(st1);

            Theme th1 = new Theme() { Name = "Theme1", Stage = st, ThemeType = _Storage.GetThemeType(1) };
            Theme th2 = new Theme() { Name = "Theme2", Stage = st1, ThemeType = _Storage.GetThemeType(1) };
            _Storage.AddTheme(th1);
            _Storage.AddTheme(th2);

            List<ThemeDescription> result = new List<ThemeDescription> { new ThemeDescription() { Theme = th1, Stage = st, Curriculum = curr,
                Timelines = new List<Timeline>() { tml } } };
            IUserService serv = _Tests.LmsService.FindService<IUserService>();
            User us = serv.GetUsers().First();
            AdvAssert.AreEqual(result, _Storage.GetThemesAvailableForUser(us));

            Timeline tml2 = new Timeline() { StageRef = st.Id, CurriculumAssignment = as1, StartDate = dtStart, EndDate = new DateTime(2011, 12, 9, 0, 0, 0) };
            _Storage.AddTimeline(tml2);
            result.Clear();
            AdvAssert.AreEqual(result, _Storage.GetThemesAvailableForUser(us));
            try
            {
                User notExistedUser = new User() { Id = Guid.NewGuid(), Username = "******", Email = "*****@*****.**", Password = "" };
                _Storage.GetThemesAvailableForUser(notExistedUser);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
        }
Example #6
0
        public void UpdateTheme()
        {
            Curriculum cur = new Curriculum() { Name = "Curriculum" };
            _Storage.AddCurriculum(cur);

            CurriculumAssignment as1 = new CurriculumAssignment() { Curriculum = cur, UserGroupRef = 1 };
            _Storage.AddCurriculumAssignment(as1);

            Stage st = new Stage() { Name = "Stage", Curriculum = cur };
            _Storage.AddStage(st);

            Theme theme = new Theme() { Name = "Theme", Stage = st, ThemeType = _Storage.GetThemeType(1) };
            int id = _Storage.AddTheme(theme);
            theme.Name = "UpdatedName";
            _Storage.UpdateTheme(theme);
            AdvAssert.AreEqual(theme, _Storage.GetTheme(id));            
            
            try
            {
                _Storage.UpdateTheme(null);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
        }
Example #7
0
        public void GetThemesByCourseId()
        {
            Curriculum cur = new Curriculum() { Name = "Curriculum", Id = 1 };
            _Storage.AddCurriculum(cur);

            Stage stage = new Stage() { Name = "Stage", Curriculum = cur, Id = 1 };
            _Storage.AddStage(stage);

            Course course = new Course() { Name = "Course", Id = 1 };
            Theme theme = new Theme() { Name = "Theme", Stage = stage, ThemeType = _Storage.GetThemeType(1), Id = 1, CourseRef = course.Id };
            Theme theme1 = new Theme() { Name = "Theme1", Stage = stage, ThemeType = _Storage.GetThemeType(1), Id = 2, CourseRef = course.Id };
            _Storage.AddTheme(theme);
            AdvAssert.AreEqual(theme, _Storage.GetThemesByCourseId(course.Id).First());
            _Storage.AddTheme(theme1);
            List<Theme> expected = new List<Theme>() { theme, theme1 };
            AdvAssert.AreEqual(expected, _Storage.GetThemesByCourseId(course.Id).ToList());
            try
            {
                _Storage.DeleteTheme(theme.Id);
                _Storage.DeleteTheme(theme1.Id);
                _Storage.GetThemesByCourseId(course.Id);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
        }
Example #8
0
        public void GetGroupsAssignedToTheme()
        {
            Curriculum cur = new Curriculum() { Name = "Curriculum" };
            Curriculum cur1 = new Curriculum() { Name = "Curriculum1" };

            IUserService userService = _Tests.LmsService.FindService<IUserService>();
            Group gr1 = userService.GetGroup(2);
            Group gr2 = userService.GetGroup(1);

            _Storage.AddCurriculum(cur);
            _Storage.AddCurriculum(cur1);

            CurriculumAssignment ass = new CurriculumAssignment() { Curriculum = cur, UserGroupRef = gr1.Id, Id = 1 };
            CurriculumAssignment ass1 = new CurriculumAssignment() { Curriculum = cur1, UserGroupRef = gr2.Id, Id = 2 };
            _Storage.AddCurriculumAssignment(ass);
            _Storage.AddCurriculumAssignment(ass1);

            Stage stage = new Stage() { Name = "Stage", Curriculum = cur };
            Stage stage1 = new Stage() { Name = "Stage1", Curriculum = cur1 };
            _Storage.AddStage(stage);
            _Storage.AddStage(stage1);

            Theme theme = new Theme() { Name = "Theme", Stage = stage, ThemeType = _Storage.GetThemeType(1) };
            Theme theme1 = new Theme() { Name = "Theme1", Stage = stage1, ThemeType = _Storage.GetThemeType(1) };
            var id = _Storage.AddTheme(theme);
            var id1 = _Storage.AddTheme(theme1);

            Assert.AreEqual(gr1.Id, _Storage.GetGroupsAssignedToTheme(id).First().Id);
            Assert.AreEqual(gr2.Id, _Storage.GetGroupsAssignedToTheme(id1).First().Id);
            _Storage.DeleteTheme(id1);
            try
            {
                _Storage.GetGroupsAssignedToTheme(id1);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
            try
            {
                _Storage.DeleteCurriculumAssignment(1);
                _Storage.GetGroupsAssignedToTheme(id);
                Assert.Fail();
            }
            catch (Exception)
            {
                Assert.True(true);
            }
        }
Example #9
0
 public void DeleteStageIfCurriculumIsDeleted()
 {
     Curriculum curriculum = new Curriculum { Name = "Curriculum" };
     var currId = _Storage.AddCurriculum(curriculum);
     Stage stage = new Stage { Name = "Stage", Curriculum = curriculum };
     var stageId = _Storage.AddStage(stage);
     _Storage.DeleteCurriculum(currId);
     Assert.AreEqual(null, _Storage.GetStage(stageId));
 }
Example #10
0
 public void DeleteStages()
 {
     var curriculums = CreateDefaultData();
     var stages = curriculums.Select(item => new Stage { Name = "Stage", Curriculum = item }).ToList();
     var ids = stages.Select(item => _Storage.AddStage(item)).ToList();
     Stage notDeleted = new Stage { Name = "NotDeletedStage", Curriculum = curriculums[0] };
     var id = _Storage.AddStage(notDeleted);
     _Storage.DeleteStages(ids);
     Assert.AreEqual(0, _Storage.GetStages(ids).ToArray().Count());
     AdvAssert.AreEqual(notDeleted, _Storage.GetStage(id));
     try
     {
         _Storage.DeleteStages(null);
         Assert.Fail();
     }
     catch (Exception)
     {
         Assert.True(true);
     }
     try
     {
         _Storage.DeleteStages(ids);
         Assert.Fail();
     }
     catch (Exception)
     {
         Assert.True(true);
     }
 }
Example #11
0
 public void UpdateStage()
 {
     Curriculum curric = new Curriculum() { Name = "Curriculum1", Id = 1 };
     Stage stage = new Stage { Name = "Stage1", Curriculum = curric, Id = 1 };
     _Storage.AddStage(stage);
     stage.Name = "ChangedName";
     _Storage.UpdateStage(stage);
     AdvAssert.AreEqual(stage, _Storage.GetStage(1));
     try
     {
         _Storage.UpdateStage(null);
         Assert.Fail();
     }
     catch (Exception)
     {
         Assert.True(true);
     }            
 }
Example #12
0
 public void MakeCurriculumInvalid()
 {
     Curriculum curriculum = new Curriculum() { Name = "Curriculum1" };
     var id = _Storage.AddCurriculum(curriculum);
     Stage stage = new Stage() { Curriculum = curriculum, Name = "Stage1" };
     _Storage.AddStage(stage);
     Theme theme = new Theme() { Name = "Theme1", Stage = stage, ThemeType = _Storage.GetThemeType(1), CourseRef = 1 };
     _Storage.AddTheme(theme);
     _Storage.MakeCurriculumInvalid(id);
     Assert.AreEqual(false, _Storage.GetCurriculum(id).IsValid);
 }
Example #13
0
 public void DeleteCourse()
 {
     Course course = _Tests.CourseStorage.GetCourse(1);
     Curriculum cur = new Curriculum() { Name = "Curriculum" };
     var currId= _Storage.AddCurriculum(cur);
     CurriculumAssignment as1 = new CurriculumAssignment() { Curriculum = cur, UserGroupRef = 1 };
     _Storage.AddCurriculumAssignment(as1);
     Stage st = new Stage() { Name = "Stage", Curriculum = cur };
     var stageId = _Storage.AddStage(st);
     Theme theme = new Theme() { Name = "Theme", Stage = st, ThemeType = _Storage.GetThemeType(1), CourseRef=course.Id };
     _Storage.AddTheme(theme);
     _Tests.CourseStorage.DeleteCourse(course.Id);
     Assert.AreEqual(false, _Storage.GetCurriculum(currId).IsValid);
 }