public void Get_diagnostic_content_should_return_null_when_data_service_returns_null()
        {
            // Given
            var emptySelectedTutorials = new List <int>();

            A.CallTo(() => diagnosticAssessmentDataService.GetDiagnosticContent(CustomisationId, SectionId))
            .Returns(null);

            // When
            var result = diagnosticAssessmentService.GetDiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials);

            // Then
            result.Should().BeNull();
        }
Пример #2
0
        public IActionResult DiagnosticContent(int customisationId, int sectionId, List <int> checkedTutorials)
        {
            var candidateId       = User.GetCandidateIdKnownNotNull();
            var centreId          = User.GetCentreId();
            var diagnosticContent = diagnosticAssessmentService.GetDiagnosticContent(customisationId, sectionId, checkedTutorials);

            if (diagnosticContent == null)
            {
                logger.LogError(
                    "Redirecting to 404 as customisation/section/centre id was not found. " +
                    $"Candidate id: {candidateId}, customisation id: {customisationId}, " +
                    $"centre id: {centreId.ToString() ?? "null"}, section id: {sectionId}");
                return(RedirectToAction("StatusCode", "LearningSolutions", new { code = 404 }));
            }

            var progressId = courseContentService.GetOrCreateProgressId(candidateId, customisationId, centreId);

            if (progressId == null)
            {
                logger.LogError(
                    "Redirecting to 404 as no progress id was returned. " +
                    $"Candidate id: {candidateId}, customisation id: {customisationId}, centre id: {centreId}");
                return(RedirectToAction("StatusCode", "LearningSolutions", new { code = 404 }));
            }

            sessionService.StartOrUpdateDelegateSession(candidateId, customisationId, HttpContext.Session);
            courseContentService.UpdateProgress(progressId.Value);

            var model = new DiagnosticContentViewModel(
                config,
                diagnosticContent,
                checkedTutorials,
                customisationId,
                centreId,
                sectionId,
                progressId.Value,
                candidateId
                );

            return(View("Diagnostic/DiagnosticContent", model));
        }