Exemplo n.º 1
0
        public void AdminFields_returns_AdminFields_page_when_appropriate_course_found_and_clears_TempData()
        {
            // Given
            var samplePrompt1 = CustomPromptsTestHelper.GetDefaultCustomPrompt(1, "System Access Granted", "Yes\r\nNo");
            var customPrompts = new List <CustomPrompt> {
                samplePrompt1
            };

            A.CallTo(() => courseAdminFieldsService.GetCustomPromptsForCourse(A <int> ._))
            .Returns(CustomPromptsTestHelper.GetDefaultCourseAdminFields(customPrompts));
            controller.TempData.Set(samplePrompt1);

            // When
            var result = controller.Index(1);

            // Then
            controller.TempData.Peek <CustomPrompt>().Should().BeNull();
            result.Should().BeViewResult().WithDefaultViewName().ModelAs <AdminFieldsViewModel>();
        }
Exemplo n.º 2
0
        public void GetCustomPromptsForCourse_Returns_Populated_CourseAdminFields()
        {
            // Given
            var expectedPrompt1 =
                CustomPromptsTestHelper.GetDefaultCustomPrompt(1, "System Access Granted", "Test");
            var expectedPrompt2 = CustomPromptsTestHelper.GetDefaultCustomPrompt(2, "Priority Access");
            var customPrompts   = new List <CustomPrompt> {
                expectedPrompt1, expectedPrompt2
            };
            var expectedCourseAdminFields = CustomPromptsTestHelper.GetDefaultCourseAdminFields(customPrompts);

            A.CallTo(() => courseAdminFieldsDataService.GetCourseAdminFields(100))
            .Returns(CustomPromptsTestHelper.GetDefaultCourseAdminFieldsResult());

            // When
            var result = courseAdminFieldsService.GetCustomPromptsForCourse(100);

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