public void AddAdminField_adds_model_error_if_field_name_is_already_in_use()
        {
            // Given
            var model           = new AddAdminFieldViewModel(1, "test");
            var initialTempData = new AddAdminFieldTempData
            {
                AdminFieldId = model.AdminFieldId, OptionsString = model.OptionsString
            };

            A.CallTo(
                () => multiPageFormService.GetMultiPageFormData <AddAdminFieldTempData>(
                    MultiPageFormDataFeature.AddAdminField,
                    controller.TempData
                    )
                ).Returns(initialTempData);
            const string action = "save";

            A.CallTo(() => courseAdminFieldsDataService.GetCourseFieldPromptIdsForCustomisation(A <int> ._))
            .Returns(new[] { 1, 0, 0 });

            // When
            var result = controller.AddAdminField(100, model, action);

            // Then
            using (new AssertionScope())
            {
                result.As <ViewResult>().Model.Should().BeOfType <AddAdminFieldViewModel>();
                AssertModelStateErrorIsExpected(result, "That field name already exists for this course");
            }
        }
Example #2
0
        public void GetCourseFieldPromptIdsForCustomisation_returns_expected_results()
        {
            // Given
            var expectedResult = new [] { 1, 2, 0 };

            // When
            var result = courseAdminFieldsDataService.GetCourseFieldPromptIdsForCustomisation(100);

            // Then
            result.Should().BeEquivalentTo(expectedResult);
        }