private static (List <CourseAdminField> adminFields, List <FilterModel> filters) GetSampleAdminFieldsAndFilters() { var adminField1 = PromptsTestHelper.GetDefaultCourseAdminField( 1, "System access", "Yes\r\nNo" ); var adminField3 = PromptsTestHelper.GetDefaultCourseAdminField(3, "Some Free Text Field"); var adminFields = new List <CourseAdminField> { adminField1, adminField3 }; var adminField1Options = new[] { new FilterOptionModel( "Yes", "Answer1(System access)" + FilteringHelper.Separator + "Answer1" + FilteringHelper.Separator + "Yes", FilterStatus.Default ), new FilterOptionModel( "No", "Answer1(System access)" + FilteringHelper.Separator + "Answer1" + FilteringHelper.Separator + "No", FilterStatus.Default ), new FilterOptionModel( "No option selected", "Answer1(System access)" + FilteringHelper.Separator + "Answer1" + FilteringHelper.Separator + FilteringHelper.EmptyValue, FilterStatus.Default ), }; var adminField3Options = new[] { new FilterOptionModel( "Not blank", "Answer3(Some Free Text Field)" + FilteringHelper.Separator + "Answer3" + FilteringHelper.Separator + FilteringHelper.FreeTextNotBlankValue, FilterStatus.Default ), new FilterOptionModel( "Blank", "Answer3(Some Free Text Field)" + FilteringHelper.Separator + "Answer3" + FilteringHelper.Separator + FilteringHelper.FreeTextBlankValue, FilterStatus.Default ), }; var adminFieldFilters = new List <FilterModel> { new FilterModel("CourseAdminField1", "System access", adminField1Options), new FilterModel("CourseAdminField3", "Some Free Text Field", adminField3Options), }; return(adminFields, adminFieldFilters); }
public void GetCourseAdminFieldsForCourse_Returns_Populated_CourseAdminFields() { // Given var expectedPrompt1 = PromptsTestHelper.GetDefaultCourseAdminField(1, "System Access Granted", "Test"); var expectedPrompt2 = PromptsTestHelper.GetDefaultCourseAdminField(2, "Priority Access"); var courseAdminFields = new List <CourseAdminField> { expectedPrompt1, expectedPrompt2 }; var expectedCourseAdminFields = PromptsTestHelper.GetDefaultCourseAdminFields(courseAdminFields); A.CallTo(() => courseAdminFieldsDataService.GetCourseAdminFields(100)) .Returns(PromptsTestHelper.GetDefaultCourseAdminFieldsResult()); // When var result = courseAdminFieldsService.GetCourseAdminFieldsForCourse(100); // Then result.Should().BeEquivalentTo(expectedCourseAdminFields); }
public void AdminFields_returns_AdminFields_page_when_appropriate_course_found_and_clears_TempData() { // Given var courseAdminField1 = PromptsTestHelper.GetDefaultCourseAdminField(1, "System Access Granted", "Yes\r\nNo"); var courseAdminFields = new List <CourseAdminField> { courseAdminField1 }; A.CallTo(() => courseAdminFieldsService.GetCourseAdminFieldsForCourse(A <int> ._)) .Returns(PromptsTestHelper.GetDefaultCourseAdminFields(courseAdminFields)); controller.TempData.Set(courseAdminField1); // When var result = controller.Index(1); // Then controller.TempData.Peek <CourseAdminField>().Should().BeNull(); result.Should().BeViewResult().WithDefaultViewName().ModelAs <AdminFieldsViewModel>(); }