public void Diagnostic_content_should_have_title() { // Given const string applicationName = "Application name"; const string customisationName = "Customisation name"; var emptySelectedTutorials = new List <int>(); var diagnosticContent = DiagnosticAssessmentTestHelper.CreateDefaultDiagnosticContent( applicationName: applicationName, customisationName: customisationName ); // When var diagnosticContentViewModel = new DiagnosticContentViewModel( config, diagnosticContent, emptySelectedTutorials, CustomisationId, CentreId, SectionId, ProgressId, CandidateId ); // Then diagnosticContentViewModel.CourseTitle.Should().Be($"{applicationName} - {customisationName}"); }
public void Diagnostic_content_should_parse_html_url_using_all_tutorials_when_can_select_tutorials_is_false() { // Given const int currentVersion = 55; const int postLearningPassThreshold = 77; const string diagnosticAssessmentPath = "https://www.dls.nhs.uk/CMS/CMSContent/Course119/Diagnostic/07DiagnosticTesting/itspplayer.html"; var selectedTutorials = new List <int>(new[] { 1, 2, 3 }); var diagnosticContent = DiagnosticAssessmentTestHelper.CreateDefaultDiagnosticContent( diagnosticAssessmentPath: diagnosticAssessmentPath, postLearningPassThreshold: postLearningPassThreshold, currentVersion: currentVersion, canSelectTutorials: false ); diagnosticContent.Tutorials.AddRange(new[] { 1, 2, 3, 4 }); // When var diagnosticContentViewModel = new DiagnosticContentViewModel( config, diagnosticContent, selectedTutorials, CustomisationId, CentreId, SectionId, ProgressId, CandidateId ); // Then diagnosticContentViewModel.ContentSource.Should().Be( "https://www.dls.nhs.uk/CMS/CMSContent/Course119/Diagnostic/07DiagnosticTesting/itspplayer.html" + "?CentreID=6&CustomisationID=5&CandidateID=8&SectionID=7&Version=55&ProgressID=9" + $"&type=diag&TrackURL={BaseUrl}/tracking/tracker&objlist=[1,2,3,4]&plathresh=77" ); }
public void Diagnostic_content_should_parse_scorm_url() { // Given const int currentVersion = 55; var emptySelectedTutorials = new List <int>(); const string diagnosticAssessmentPath = "https://www.dls.nhs.uk/CMS/CMSContent/Course38/Diagnostic/03_Digital_Literacy_Diag/imsmanifest.xml"; var diagnosticContent = DiagnosticAssessmentTestHelper.CreateDefaultDiagnosticContent( diagnosticAssessmentPath: diagnosticAssessmentPath, currentVersion: currentVersion ); // When var diagnosticContentViewModel = new DiagnosticContentViewModel( config, diagnosticContent, emptySelectedTutorials, CustomisationId, CentreId, SectionId, ProgressId, CandidateId ); // Then diagnosticContentViewModel.ContentSource.Should().Be( $"{BaseUrl}/scoplayer/sco?CentreID=6&CustomisationID=5&CandidateID=8&SectionID=7&Version=55" + "&tutpath=https://www.dls.nhs.uk/CMS/CMSContent/Course38/Diagnostic/03_Digital_Literacy_Diag/imsmanifest.xml&type=diag" ); }
public void Diagnostic_content_should_render_view() { // Given const int progressId = 299; var emptySelectedTutorials = new List <int>(); var selectedTutorials = new List <int>(); var defaultDiagnosticContent = DiagnosticAssessmentTestHelper.CreateDefaultDiagnosticContent(); A.CallTo(() => diagnosticAssessmentService.GetDiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials)) .Returns(defaultDiagnosticContent); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)). Returns(progressId); // When var result = controller.DiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials); // Then var expectedModel = new DiagnosticContentViewModel( config, defaultDiagnosticContent, selectedTutorials, CustomisationId, CentreId, SectionId, progressId, CandidateId); result.Should().BeViewResult() .Model.Should().BeEquivalentTo(expectedModel); }
public void Get_diagnostic_content_should_return_diagnostic_content_from_data_service_if_selection_is_disabled() { // Given var emptySelectedTutorials = new List <int>(); var diagnosticContent = DiagnosticAssessmentTestHelper.CreateDefaultDiagnosticContent(canSelectTutorials: false); A.CallTo(() => diagnosticAssessmentDataService.GetDiagnosticContent(CustomisationId, SectionId)) .Returns(diagnosticContent); // When var result = diagnosticAssessmentService.GetDiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials); // Then result.Should().BeEquivalentTo(diagnosticContent); }
public void Diagnostic_content_should_not_StartOrUpdate_course_sessions_if_unable_to_enrol() { // Given var emptySelectedTutorials = new List <int>(); var defaultDiagnosticContent = DiagnosticAssessmentTestHelper.CreateDefaultDiagnosticContent(); A.CallTo(() => diagnosticAssessmentService.GetDiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials)) .Returns(defaultDiagnosticContent); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)) .Returns(null); // When controller.DiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials); // Then A.CallTo(() => sessionService.StartOrUpdateDelegateSession(A <int> ._, A <int> ._, A <ISession> ._)).MustNotHaveHappened(); }
public void Diagnostic_content_should_UpdateProgress_if_valid_diagnostic_content() { // Given var emptySelectedTutorials = new List <int>(); const int progressId = 299; var defaultDiagnosticContent = DiagnosticAssessmentTestHelper.CreateDefaultDiagnosticContent(); A.CallTo(() => diagnosticAssessmentService.GetDiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials)) .Returns(defaultDiagnosticContent); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)) .Returns(progressId); // When controller.DiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials); // Then A.CallTo(() => courseContentService.UpdateProgress(progressId)).MustHaveHappened(); }
public void Diagnostic_content_should_404_if_failed_to_enrol() { // Given var emptySelectedTutorials = new List <int>(); var defaultDiagnosticContent = DiagnosticAssessmentTestHelper.CreateDefaultDiagnosticContent(); A.CallTo(() => diagnosticAssessmentService.GetDiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials)) .Returns(defaultDiagnosticContent); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(null); // When var result = controller.DiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials); // Then result.Should() .BeRedirectToActionResult() .WithControllerName("LearningSolutions") .WithActionName("StatusCode") .WithRouteValue("code", 404); }
public void Diagnostic_content_should_have_customisation_id() { // Given const int customisationId = 11; var emptySelectedTutorials = new List <int>(); var diagnosticContent = DiagnosticAssessmentTestHelper.CreateDefaultDiagnosticContent(); // When var diagnosticContentViewModel = new DiagnosticContentViewModel( config, diagnosticContent, emptySelectedTutorials, customisationId, CentreId, SectionId, ProgressId, CandidateId ); // Then diagnosticContentViewModel.CustomisationId.Should().Be(customisationId); }
public void Get_diagnostic_content_should_return_null_if_some_selected_tutorials_are_invalid() { // Given var diagnosticContent = DiagnosticAssessmentTestHelper.CreateDefaultDiagnosticContent(canSelectTutorials: true); diagnosticContent.Tutorials.AddRange(new[] { 1, 2, 3 }); var selectedTutorials = new List <int>(new[] { 3, 4, 5 }); A.CallTo(() => diagnosticAssessmentDataService.GetDiagnosticContent(CustomisationId, SectionId)) .Returns(diagnosticContent); // When var result = diagnosticAssessmentService.GetDiagnosticContent(CustomisationId, SectionId, selectedTutorials); // Then result.Should().BeNull(); }
public void Diagnostic_content_should_StartOrUpdate_course_sessions_if_valid_diagnostic_content() { // Given const int progressId = 299; var emptySelectedTutorials = new List <int>(); var defaultDiagnosticContent = DiagnosticAssessmentTestHelper.CreateDefaultDiagnosticContent(); A.CallTo(() => diagnosticAssessmentService.GetDiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials)) .Returns(defaultDiagnosticContent); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)) .Returns(progressId); // When controller.DiagnosticContent(CustomisationId, SectionId, emptySelectedTutorials); // Then A.CallTo(() => sessionService.StartOrUpdateDelegateSession(CandidateId, CustomisationId, httpContextSession)).MustHaveHappenedOnceExactly(); A.CallTo(() => sessionService.StartOrUpdateDelegateSession(A <int> ._, A <int> ._, A <ISession> ._)) .WhenArgumentsMatch((int candidateId, int customisationId, ISession session) => candidateId != CandidateId || customisationId != CustomisationId) .MustNotHaveHappened(); }
public void Diagnostic_content_should_have_section_name() { // Given const string sectionName = "Section name"; var emptySelectedTutorials = new List <int>(); var diagnosticContent = DiagnosticAssessmentTestHelper.CreateDefaultDiagnosticContent( sectionName: sectionName ); // When var diagnosticContentViewModel = new DiagnosticContentViewModel( config, diagnosticContent, emptySelectedTutorials, CustomisationId, CentreId, SectionId, ProgressId, CandidateId ); // Then diagnosticContentViewModel.SectionName.Should().Be(sectionName); }