示例#1
0
        public void GetDelegateAttemptsAndCourseCustomPrompts_should_call_correct_data_service_and_helper_methods()
        {
            // Given
            const int delegateId      = 20;
            const int customisationId = 111;
            var       attemptStatsReturnedByDataService = new AttemptStats(10, 5);
            var       info = new DelegateCourseInfo
            {
                DelegateId = delegateId, CustomisationId = customisationId, IsAssessed = true
            };

            A.CallTo(() => courseDataService.GetDelegateCourseAttemptStats(delegateId, customisationId))
            .Returns(attemptStatsReturnedByDataService);

            // When
            var results = courseService.GetDelegateAttemptsAndCourseCustomPrompts(info);

            // Then
            A.CallTo(
                () => courseAdminFieldsService.GetCustomPromptsWithAnswersForCourse(
                    info,
                    customisationId
                    )
                ).MustHaveHappenedOnceExactly();
            A.CallTo(() => courseDataService.GetDelegateCourseAttemptStats(delegateId, customisationId))
            .MustHaveHappenedOnceExactly();
            results.DelegateCourseInfo.Should().BeEquivalentTo(info);
            results.AttemptStats.Should().Be(attemptStatsReturnedByDataService);
        }
示例#2
0
        public void GetCustomPromptsWithAnswersForCourse_Returns_Populated_List_of_CustomPromptWithAnswer()
        {
            // Given
            const string answer1   = "ans1";
            const string answer2   = "ans2";
            var          expected1 = CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(
                1,
                "System Access Granted",
                "Test",
                answer: answer1
                );
            var expected2 = CustomPromptsTestHelper.GetDefaultCustomPromptWithAnswer(
                2,
                "Priority Access",
                answer: answer2
                );
            var expected = new List <CustomPromptWithAnswer> {
                expected1, expected2
            };

            A.CallTo(() => courseAdminFieldsDataService.GetCourseAdminFields(100))
            .Returns(CustomPromptsTestHelper.GetDefaultCourseAdminFieldsResult());
            var delegateCourseInfo = new DelegateCourseInfo {
                Answer1 = answer1, Answer2 = answer2
            };

            // When
            var result = courseAdminFieldsService.GetCustomPromptsWithAnswersForCourse(delegateCourseInfo, 100);

            // Then
            result.Should().BeEquivalentTo(expected);
        }
示例#3
0
        public DelegateCourseDetails GetDelegateAttemptsAndCourseCustomPrompts(
            DelegateCourseInfo info
            )
        {
            var customPrompts = courseAdminFieldsService.GetCustomPromptsWithAnswersForCourse(
                info,
                info.CustomisationId
                );

            var attemptStats = info.IsAssessed
                ? courseDataService.GetDelegateCourseAttemptStats(info.DelegateId, info.CustomisationId)
                : new AttemptStats(0, 0);

            return(new DelegateCourseDetails(info, customPrompts, attemptStats));
        }