SetSectionContent_get_redirects_to_summary_if_section_has_no_tutorials_and_there_are_no_sections_left() { // Given var section = new Section(1, "Test name 1"); var courseContentTempData = new CourseContentTempData( new List <Section> { section }, false, new List <int> { 1 } ); SetAddNewCentreCourseTempData(application, courseContentTempData: courseContentTempData); A.CallTo( () => tutorialService.GetTutorialsForSection(1) ).Returns(new List <Tutorial>()); // When var result = controller.SetSectionContent(0); // Then result.Should().BeRedirectToActionResult().WithActionName("Summary"); }
public void SetSectionContent_post_updates_temp_data_and_redirects_to_next_section_if_there_is_one() { // Given var section1 = new Section(1, "Test name 1"); var section2 = new Section(2, "Test name 2"); var model = new SetSectionContentViewModel(section1, 0, true); var courseContentTempData = new CourseContentTempData( new List <Section> { section1, section2 }, false, new List <int> { 1, 2 } ); SetAddNewCentreCourseTempData(application, courseContentTempData: courseContentTempData); A.CallTo( () => tutorialService.GetTutorialsForSection(A <int> ._) ).Returns(new List <Tutorial> { new Tutorial(1, "Test name", true, true) }); // When var result = controller.SetSectionContent(model, "save"); // Then using (new AssertionScope()) { A.CallTo( () => multiPageFormService.SetMultiPageFormData( A <AddNewCentreCourseTempData> .That.Matches(d => d.SectionContentData != null), MultiPageFormDataFeature.AddNewCourse, controller.TempData ) ).MustHaveHappenedOnceExactly(); result.Should().BeRedirectToActionResult().WithActionName("SetSectionContent"); } }
public SetCourseContentViewModel(CourseContentTempData tempData) { IncludeAllSections = tempData.IncludeAllSections; AvailableSections = tempData.AvailableSections; SelectedSectionIds = tempData.SelectedSectionIds; }