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");
            }
        }
Esempio n. 2
0
        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 expectedViewModel    = new EditAdminFieldViewModel(1, "Test", "Test\r\nAnswer");
            var initialTempData      = new EditAdminFieldData(initialEditViewModel);

            controller.TempData.Set(initialTempData);

            A.CallTo(() => courseService.VerifyAdminUserCanManageCourse(A <int> ._, A <int> ._, A <int> ._))
            .Returns(true);

            // When
            var result = controller.EditAdminFieldAnswersBulk(1, 1, inputViewModel);

            // Then
            using (new AssertionScope())
            {
                AssertEditTempDataIsExpected(expectedViewModel);
                result.Should().BeRedirectToActionResult().WithActionName("EditAdminField");
            }
        }