public void UpdateModuleName() { var courseName = "Course with modules"; var courseRepo = new CoachingCourseRepositoryDocumentDB(); var moduleRepo = new CoachingModuleRepositoryDocumentDB(); var course = new CoachingCourse(courseName); courseRepo.CreateCoachingCourse(course); var introduction = new CoachingModuleResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Content = "<h1><Overskrift her></h1> <p><Kort tekst her></p> <div data-oembed-url='https://vimeo.com/ricardonilsson/coachingwill'> <div style='left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 56.2493%;'><iframe allowfullscreen='true' frameborder='0' mozallowfullscreen='true' src='//player.vimeo.com/video/77308630?byline=0&badge=0&portrait=0&title=0' style='top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;' webkitallowfullscreen='true'></iframe></div> </div> <h2><Overskrift, start på udvidet intro></h2> <p><Intro her></p> <h2><Overskrift, eksterne henvisninger></h2> <p><a href='http://wikipedia.org'><Eksempel på link></a></p>" }; var exercise = new CoachingModuleExerciseResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Elements = new List <ResourceExerciseElement>() { new ResourceExerciseElement("<h1><Overskrift her></h1> <p><Kort tekst her, efterfulgt af ></p> <SortableList/>") } }; var reflection = new CoachingModuleExerciseResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Elements = new List <ResourceExerciseElement>() { new ResourceExerciseElement("<h1><Overskrift her></h1> <p><Kort tekst her></p> <h2> </h2>") } }; var module = new CoachingModule ( "Some module, that is gonna have its name changed", introduction, exercise, reflection ); course.AddCoachingModule(module); moduleRepo.CreateModule(module); courseRepo.SaveCoachingCourse(course); moduleRepo = new CoachingModuleRepositoryDocumentDB(); var foundModule = moduleRepo.GetItems(m => m.Id == module.Id).Single(); Assert.IsNotNull(foundModule); module.Name = "Some module with a new name"; moduleRepo.SaveModule(module); moduleRepo = new CoachingModuleRepositoryDocumentDB(); var newFoundModule = moduleRepo.GetItems(m => m.Id == module.Id).Single(); Assert.AreEqual(newFoundModule.Name, "Some module with a new name"); }
public void CreateAndFindNewCourse() { var courseName = "Test coaching course"; var courseRepo = new CoachingCourseRepositoryDocumentDB(); var course = new CoachingCourse(courseName); courseRepo.CreateCoachingCourse(course); courseRepo.SaveCoachingCourse(course); courseRepo = new CoachingCourseRepositoryDocumentDB(); var foundCourses = courseRepo.GetItems(c => c.Name == courseName).Single(); Assert.IsNotNull(foundCourses); }
public void GetMultipleModulesWithSpecificIds() { var courseName = "Course with multiple modules"; var courseRepo = new CoachingCourseRepositoryDocumentDB(); var moduleRepo = new CoachingModuleRepositoryDocumentDB(); var course = new CoachingCourse(courseName); courseRepo.CreateCoachingCourse(course); var introduction1 = new CoachingModuleResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Content = "<h1><Overskrift her></h1> <p><Kort tekst her></p> <div data-oembed-url='https://vimeo.com/ricardonilsson/coachingwill'> <div style='left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 56.2493%;'><iframe allowfullscreen='true' frameborder='0' mozallowfullscreen='true' src='//player.vimeo.com/video/77308630?byline=0&badge=0&portrait=0&title=0' style='top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;' webkitallowfullscreen='true'></iframe></div> </div> <h2><Overskrift, start på udvidet intro></h2> <p><Intro her></p> <h2><Overskrift, eksterne henvisninger></h2> <p><a href='http://wikipedia.org'><Eksempel på link></a></p>" }; var exercise1 = new CoachingModuleExerciseResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Elements = new List <ResourceExerciseElement>() { new ResourceExerciseElement("<h1><Overskrift her></h1> <p><Kort tekst her, efterfulgt af ></p> <SortableList/>") } }; var reflection1 = new CoachingModuleExerciseResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Elements = new List <ResourceExerciseElement>() { new ResourceExerciseElement("<h1><Overskrift her></h1> <p><Kort tekst her></p> <h2> </h2>") } }; var module1 = new CoachingModule ( "My coaching module 1", introduction1, exercise1, reflection1 ); var introduction2 = new CoachingModuleResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Content = "<h1><Overskrift her></h1> <p><Kort tekst her></p> <div data-oembed-url='https://vimeo.com/ricardonilsson/coachingwill'> <div style='left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 56.2493%;'><iframe allowfullscreen='true' frameborder='0' mozallowfullscreen='true' src='//player.vimeo.com/video/77308630?byline=0&badge=0&portrait=0&title=0' style='top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;' webkitallowfullscreen='true'></iframe></div> </div> <h2><Overskrift, start på udvidet intro></h2> <p><Intro her></p> <h2><Overskrift, eksterne henvisninger></h2> <p><a href='http://wikipedia.org'><Eksempel på link></a></p>" }; var exercise2 = new CoachingModuleExerciseResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Elements = new List <ResourceExerciseElement>() { new ResourceExerciseElement("<h1><Overskrift her></h1> <p><Kort tekst her, efterfulgt af ></p> <SortableList/>") } }; var reflection2 = new CoachingModuleExerciseResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Elements = new List <ResourceExerciseElement>() { new ResourceExerciseElement("<h1><Overskrift her></h1> <p><Kort tekst her></p> <h2> </h2>") } }; var module2 = new CoachingModule ( "My coaching module 2", introduction2, exercise2, reflection2 ); var introduction3 = new CoachingModuleResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Content = "<h1><Overskrift her></h1> <p><Kort tekst her></p> <div data-oembed-url='https://vimeo.com/ricardonilsson/coachingwill'> <div style='left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 56.2493%;'><iframe allowfullscreen='true' frameborder='0' mozallowfullscreen='true' src='//player.vimeo.com/video/77308630?byline=0&badge=0&portrait=0&title=0' style='top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;' webkitallowfullscreen='true'></iframe></div> </div> <h2><Overskrift, start på udvidet intro></h2> <p><Intro her></p> <h2><Overskrift, eksterne henvisninger></h2> <p><a href='http://wikipedia.org'><Eksempel på link></a></p>" }; var exercise3 = new CoachingModuleExerciseResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Elements = new List <ResourceExerciseElement>() { new ResourceExerciseElement("<h1><Overskrift her></h1> <p><Kort tekst her, efterfulgt af ></p> <SortableList/>") } }; var reflection3 = new CoachingModuleExerciseResource() { RevisionHistory = new ResourseRevisionHistoryReference(), Elements = new List <ResourceExerciseElement>() { new ResourceExerciseElement("<h1><Overskrift her></h1> <p><Kort tekst her></p> <h2> </h2>") } }; var module3 = new CoachingModule ( "My coaching module 2", introduction3, exercise3, reflection3 ); course.AddCoachingModule(module1); course.AddCoachingModule(module2); course.AddCoachingModule(module3); courseRepo.SaveCoachingCourse(course); moduleRepo.SaveModule(module1); moduleRepo.SaveModule(module2); moduleRepo.SaveModule(module3); courseRepo = new CoachingCourseRepositoryDocumentDB(); moduleRepo = new CoachingModuleRepositoryDocumentDB(); var foundCourses = courseRepo.GetItems(c => c.Name == courseName).Single(); var foundModules = moduleRepo.GetItemsWithIds(foundCourses.Modules.Select(m => m.ModuleReferenceId)).ToList(); Assert.AreEqual(foundModules.Count(), 3); Assert.IsNotNull(foundCourses); }