public void AddRegistrationPromptSelectPrompt_post_updates_temp_data_and_redirects() { // Given var expectedPromptData = new AddRegistrationPromptSelectPromptData(1, true, "prompt"); var initialTempData = new AddRegistrationPromptTempData(); A.CallTo( () => multiPageFormService.GetMultiPageFormData <AddRegistrationPromptTempData>( MultiPageFormDataFeature.AddRegistrationPrompt, registrationPromptsController.TempData ) ).Returns(initialTempData); A.CallTo(() => centreRegistrationPromptsService.GetCentreRegistrationPromptsAlphabeticalList()) .Returns(new List <(int id, string value)> { (1, "prompt") }); var inputViewModel = new AddRegistrationPromptSelectPromptViewModel(1, true); // When var result = registrationPromptsController.AddRegistrationPromptSelectPrompt(inputViewModel); // Then AssertMultiPageFormDataIsUpdatedCorrectly(expectedPromptData, new RegistrationPromptAnswersTempData()); result.Should().BeRedirectToActionResult().WithActionName("AddRegistrationPromptConfigureAnswers"); }
public void GetMultiPageFormData_throws_exception_when_TempData_Guid_is_null() { // When Action act = () => multiPageFormService.GetMultiPageFormData <int>( MultiPageFormDataFeature.AddNewCourse, tempDataDictionary ); // Then act.Should().Throw <MultiPageFormDataException>() .WithMessage("Attempted to get data with no Guid identifier"); }
public IActionResult EditAdminField(int customisationId) { var data = multiPageFormService.GetMultiPageFormData <EditAdminFieldTempData>( MultiPageFormDataFeature.EditAdminField, TempData ); return(View(new EditAdminFieldViewModel(data))); }
public IActionResult EditRegistrationPrompt() { var data = multiPageFormService.GetMultiPageFormData <EditRegistrationPromptTempData>( MultiPageFormDataFeature.EditRegistrationPrompt, TempData ); return(View(new EditRegistrationPromptViewModel(data))); }
public void EditAdminFieldAnswersBulk_updates_temp_data_and_redirects_to_edit() { // Given var inputViewModel = new BulkAdminFieldAnswersViewModel("Test\r\nAnswer"); var initialEditViewModel = new EditAdminFieldViewModel(1, "Test", "Test"); var initialTempData = new EditAdminFieldTempData { PromptNumber = initialEditViewModel.PromptNumber, Prompt = initialEditViewModel.Prompt, OptionsString = initialEditViewModel.OptionsString, Answer = initialEditViewModel.Answer, IncludeAnswersTableCaption = initialEditViewModel.IncludeAnswersTableCaption, }; A.CallTo( () => multiPageFormService.GetMultiPageFormData <EditAdminFieldTempData>( MultiPageFormDataFeature.EditAdminField, controller.TempData ) ).Returns(initialTempData); A.CallTo(() => courseService.VerifyAdminUserCanManageCourse(A <int> ._, A <int> ._, A <int> ._)) .Returns(true); // When var result = controller.EditAdminFieldAnswersBulk(1, inputViewModel); // Then using (new AssertionScope()) { A.CallTo( () => multiPageFormService.SetMultiPageFormData( A <EditAdminFieldTempData> .That.Matches( d => d.PromptNumber == initialTempData.PromptNumber && d.Prompt == initialTempData.Prompt && d.Answer == initialTempData.Answer && d.IncludeAnswersTableCaption == initialTempData.IncludeAnswersTableCaption && d.OptionsString == inputViewModel.OptionsString ), MultiPageFormDataFeature.EditAdminField, controller.TempData ) ).MustHaveHappenedOnceExactly(); result.Should().BeRedirectToActionResult().WithActionName("EditAdminField"); } }
public IActionResult SelectCourse( string?categoryFilterString = null, string?topicFilterString = null ) { var data = multiPageFormService.GetMultiPageFormData <AddNewCentreCourseTempData>( MultiPageFormDataFeature.AddNewCourse, TempData ); var model = GetSelectCourseViewModel( categoryFilterString ?? data.CategoryFilter, topicFilterString ?? data.TopicFilter, data.Application?.ApplicationId ); return(View("AddNewCentreCourse/SelectCourse", model)); }