// GET api/values/5
        public ModuleExerciseResourceDTO Get(Guid id)
        {
            var exerciseRepository = new CoachnigModuleExerciseResourceRepositoryDocumentDB();

            return(ModuleResourceDTOConverter.ConvertToDTO(
                       exerciseRepository.GetItems(i => i.Id == id).SingleOrDefault()));
        }
示例#2
0
        public void AddModuleViaService()
        {
            var courseName = "Service test course with modules";
            //Create the course
            var course = _coachingCourseService.CreateNewCoachingCourse(courseName);

            _coachingCourseService.CreateNewModuleInCourse(course, "Some module", 0);

            //Check that revisions histories was created
            var resourceRepo = new ModuleResourceRepositoryDocumentDb();
            var exerciseRepo = new CoachnigModuleExerciseResourceRepositoryDocumentDB();
            var moduleRepo   = new CoachingModuleRepositoryDocumentDB();
            var foundModule  = moduleRepo.GetModuleById(course.Modules[0].ModuleReferenceId);

            //Check that repos only has one version
            Assert.AreEqual(resourceRepo.GetItems(i => i.RevisionHistory.ReferenceId == foundModule.Introduction.RevisionHistoryReferenceId).Count(), 1);
            Assert.AreEqual(exerciseRepo.GetItems(i => i.RevisionHistory.ReferenceId == foundModule.Exercise.RevisionHistoryReferenceId).Count(), 1);
            Assert.AreEqual(exerciseRepo.GetItems(i => i.RevisionHistory.ReferenceId == foundModule.Reflection.RevisionHistoryReferenceId).Count(), 1);

            Assert.AreNotEqual(foundModule.Introduction.RevisionHistoryReferenceId, foundModule.Exercise.RevisionHistoryReferenceId);
            Assert.AreNotEqual(foundModule.Introduction.RevisionHistoryReferenceId, foundModule.Reflection.RevisionHistoryReferenceId);
            Assert.AreNotEqual(foundModule.Exercise.RevisionHistoryReferenceId, foundModule.Reflection.RevisionHistoryReferenceId);
        }