public void Tutorial_should_have_showNextButton( string status, bool otherSectionsExist, bool otherItemsInSectionExist, bool expectedShowNextButton ) { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( status: status, otherSectionsExist: otherSectionsExist, otherItemsInSectionExist: otherItemsInSectionExist ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.ShowNextButton.Should().Be(expectedShowNextButton); }
public async Task Tutorial_should_sign_in_with_longer_expiry_if_valid_tutorial_with_average_duration_of_45_minutes_or_over(int averageTutorialDuration) { // Given var utcNow = new DateTime(2022, 1, 1, 10, 0, 0); var defaultTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId, averageTutorialDuration: averageTutorialDuration); A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId)) .Returns(defaultTutorialInformation); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(1); A.CallTo(() => clockService.UtcNow).Returns(utcNow); // When await controller.Tutorial(CustomisationId, SectionId, TutorialId); // Then var expectedExpiryTime = new DateTime(2022, 1, 1, 18, 0, 0); A.CallTo( () => authenticationService.SignInAsync( A <HttpContext> ._, A <string> ._, A <ClaimsPrincipal> ._, A <AuthenticationProperties> .That.Matches(ap => ap.ExpiresUtc !.Value == expectedExpiryTime) ) ).MustHaveHappenedOnceExactly(); }
public void Tutorial_parses_html_document_of_objectives() { // Given const string objectives = "<html> <head> <title>Tutorial Objective</title> </head>" + "<body> In this tutorial you will learn to: " + "<ul>" + "<li>open another window on to a workbook</li>" + "<li>arrange workbook windows</li>" + "<li>hide and show windows</li>" + "</ul>" + "</body> </html>"; var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( objectives: objectives ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.Objectives.Should().Be(" In this tutorial you will learn to: " + "<ul>" + "<li>open another window on to a workbook</li>" + "<li>arrange workbook windows</li>" + "<li>hide and show windows</li>" + "</ul>"); }
public void ContentViewer_should_render_view() { // Given var expectedTutorialContent = TutorialContentHelper.CreateDefaultTutorialContent(); const int progressId = 101; A.CallTo(() => tutorialContentDataService.GetTutorialContent(CustomisationId, SectionId, TutorialId)) .Returns(expectedTutorialContent); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)) .Returns(progressId); // When var result = controller.ContentViewer(CustomisationId, SectionId, TutorialId); // Then var expectedModel = new ContentViewerViewModel( config, expectedTutorialContent, CustomisationId, CentreId, SectionId, TutorialId, CandidateId, progressId ); result.Should().BeViewResult() .Model.Should().BeEquivalentTo(expectedModel); }
public void Tutorial_should_have_timeSummary( int timeSpent, int averageTutorialDuration, bool showTime, bool showLearnStatus ) { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( timeSpent: timeSpent, averageTutorialDuration: averageTutorialDuration, courseSettings: "{\"lm.st\":" + showTime.ToString().ToLower() + ", \"lm.sl\":" + showLearnStatus.ToString().ToLower() + "}" ); var expectedTimeSummary = new TutorialTimeSummaryViewModel( timeSpent, averageTutorialDuration, showTime, showLearnStatus ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.TimeSummary.Should().BeEquivalentTo(expectedTimeSummary); }
public void Tutorial_should_have_nextLinkViewModel() { // Given const string postLearningAssessmentPath = "/assessment"; const int nextTutorialId = 101; const int nextSectionId = 100; var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( nextTutorialId: nextTutorialId, nextSectionId: nextSectionId, postLearningAssessmentPath: postLearningAssessmentPath ); var expectedNextLinkViewModel = new TutorialNextLinkViewModel( CustomisationId, SectionId, postLearningAssessmentPath, nextTutorialId, nextSectionId ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.NextLinkViewModel.Should().BeEquivalentTo(expectedNextLinkViewModel); }
public void Tutorial_should_have_showCompletionSummary( bool otherSectionsExist, bool otherItemsInSectionExist, bool includeCertification, bool expectedShowCompletionSummary ) { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( otherSectionsExist: otherSectionsExist, otherItemsInSectionExist: otherItemsInSectionExist, includeCertification: includeCertification ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.ShowCompletionSummary.Should().Be(expectedShowCompletionSummary); }
public void Content_viewer_should_parse_html_source() { // Given const int customisationId = 24861; var expectedHtmlUrl = "https://www.dls.nhs.uk/CMS/CMSContent/Course508/Section1904/Tutorials/Intro to Social Media/itspplayer.html" + "?CentreID=101&CustomisationID=24861&TutorialID=4&CandidateID=254480&Version=2&ProgressID=276837&type=learn" + $"&TrackURL={BaseUrl}/tracking/tracker"; // Given var expectedTutorialContent = TutorialContentHelper.CreateDefaultTutorialContent( currentVersion: 2, tutorialPath: "https://www.dls.nhs.uk/CMS/CMSContent/Course508/Section1904/Tutorials/Intro to Social Media/itspplayer.html" ); // When var contentViewerViewModel = new ContentViewerViewModel( config, expectedTutorialContent, customisationId, CentreId, SectionId, TutorialId, CandidateId, ProgressId ); // Then contentViewerViewModel.ContentSource.Should().Be(expectedHtmlUrl); }
public void Content_viewer_should_parse_scorm_source() { // Given var expectedTutorialContent = TutorialContentHelper.CreateDefaultTutorialContent( currentVersion: 1, tutorialPath: "https://www.dls.nhs.uk/cms/CMSContent/Course589/Section2295/Tutorials/2 Patient Reg PDS/imsmanifest.xml" ); var expectedScormUrl = $"{BaseUrl}/scoplayer/sco?CentreID=101&CustomisationID=37545&TutorialID=4&CandidateID=254480&Version=1" + "&tutpath=https://www.dls.nhs.uk/cms/CMSContent/Course589/Section2295/Tutorials/2 Patient Reg PDS/imsmanifest.xml"; // When var contentViewerViewModel = new ContentViewerViewModel( config, expectedTutorialContent, CustomisationId, CentreId, SectionId, TutorialId, CandidateId, ProgressId ); // Then contentViewerViewModel.ContentSource.Should().Be(expectedScormUrl); }
public void Content_viewer_should_have_courseTitle() { // Given const string applicationName = "Application Name"; const string customisationName = "Customisation Name"; var expectedTutorialContent = TutorialContentHelper.CreateDefaultTutorialContent( applicationName: applicationName, customisationName: customisationName ); // When var contentViewerViewModel = new ContentViewerViewModel( config, expectedTutorialContent, CustomisationId, CentreId, SectionId, TutorialId, CandidateId, ProgressId ); // Then var courseTitle = $"{applicationName} - {customisationName}"; contentViewerViewModel.CourseTitle.Should().BeEquivalentTo(courseTitle); }
public async Task Tutorial_should_not_UpdateProgress_if_unable_to_enrol() { // Given var defaultTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId); A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId)) .Returns(defaultTutorialInformation); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(null); // When await controller.Tutorial(CustomisationId, SectionId, TutorialId); // Then A.CallTo(() => courseContentService.UpdateProgress(A <int> ._)).MustNotHaveHappened(); }
public void Tutorial_should_not_StartOrUpdate_course_sessions_if_unable_to_enrol() { // Given var defaultTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId); A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId)) .Returns(defaultTutorialInformation); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(null); // When controller.Tutorial(CustomisationId, SectionId, TutorialId); // Then A.CallTo(() => sessionService.StartOrUpdateDelegateSession(A <int> ._, A <int> ._, A <ISession> ._)).MustNotHaveHappened(); }
public void Tutorial_should_have_tutorialId() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.TutorialId.Should().Be(TutorialId); }
public void ContentViewer_should_not_UpdateProgress_if_unable_to_enrol() { // Given var expectedTutorialContent = TutorialContentHelper.CreateDefaultTutorialContent(); A.CallTo(() => tutorialContentDataService.GetTutorialContent(CustomisationId, SectionId, TutorialId)) .Returns(expectedTutorialContent); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)) .Returns(null); // When controller.ContentViewer(CustomisationId, SectionId, TutorialId); // Then A.CallTo(() => courseContentService.UpdateProgress(A<int>._)).MustNotHaveHappened(); }
public async Task Tutorial_should_UpdateProgress_if_valid_tutorial() { // Given const int progressId = 3; var defaultTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId); A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId)) .Returns(defaultTutorialInformation); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(progressId); // When await controller.Tutorial(CustomisationId, SectionId, TutorialId); // Then A.CallTo(() => courseContentService.UpdateProgress(progressId)).MustHaveHappened(); }
public void TutorialVideo_should_have_sectionId() { // Given var expectedTutorialVideo = TutorialContentHelper.CreateDefaultTutorialVideo(); // When var tutorialVideoViewModel = new TutorialVideoViewModel( config, expectedTutorialVideo, CustomisationId, SectionId, TutorialId ); // Then tutorialVideoViewModel.SectionId.Should().Be(SectionId); }
public void Tutorial_handles_null_objectives() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( objectives: null ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.Objectives.Should().BeNull(); }
public void Tutorial_should_have_default_showLearnStatus_when_courseSetting_is_empty() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( courseSettings: null ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.ShowLearnStatus.Should().BeTrue(); }
public void Tutorial_start_button_should_say_start_tutorial_if_tutorial_status_is_not_complete(string status) { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( status: status ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.TutorialStartButtonText.Should().Be("Start tutorial"); }
public void Tutorial_start_button_should_be_grey_if_tutorial_status_is_complete() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( status: "Complete" ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.TutorialStartButtonAdditionalStyling.Should().Be("nhsuk-button--secondary"); }
public void Tutorial_should_have_showLearnStatus_from_courseSetting() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( courseSettings: "{\"lm.sl\":false}" ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.ShowLearnStatus.Should().BeFalse(); }
public void Tutorial_should_have_default_supportingMaterialsLabel_when_courseSetting_is_empty() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( courseSettings: null ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.SupportingMaterialsLabel.Should().Be("Download supporting materials"); }
public async Task Tutorial_should_render_view() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId); A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId)) .Returns(expectedTutorialInformation); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(3); // When var result = await controller.Tutorial(CustomisationId, SectionId, TutorialId); // Then var expectedModel = new TutorialViewModel(config, expectedTutorialInformation, CustomisationId, SectionId); result.Should().BeViewResult() .Model.Should().BeEquivalentTo(expectedModel); }
public void Tutorial_should_have_completion_summary_card_view_model( int customisationId, string?completed, int maxPostLearningAssessmentAttempts, bool isAssessed, int postLearningAssessmentPassThreshold, int diagnosticAssessmentCompletionThreshold, int tutorialsCompletionThreshold ) { // Given var completedDateTime = completed != null?DateTime.Parse(completed) : (DateTime?)null; var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( completed: completedDateTime, maxPostLearningAssessmentAttempts: maxPostLearningAssessmentAttempts, isAssessed: isAssessed, postLearningAssessmentPassThreshold: postLearningAssessmentPassThreshold, diagnosticAssessmentCompletionThreshold: diagnosticAssessmentCompletionThreshold, tutorialsCompletionThreshold: tutorialsCompletionThreshold ); var expectedCompletionSummaryViewModel = new CompletionSummaryCardViewModel( customisationId, completedDateTime, maxPostLearningAssessmentAttempts, isAssessed, postLearningAssessmentPassThreshold, diagnosticAssessmentCompletionThreshold, tutorialsCompletionThreshold ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, customisationId, SectionId ); // Then tutorialViewModel.CompletionSummaryCardViewModel .Should().BeEquivalentTo(expectedCompletionSummaryViewModel); }
public async Task Tutorial_should_StartOrUpdate_course_sessions_if_valid_tutorial() { // Given var defaultTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId); A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId)) .Returns(defaultTutorialInformation); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(1); // When await controller.Tutorial(CustomisationId, SectionId, TutorialId); // 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 Tutorial_should_not_decide_to_show_progress_when_canShowDiagnosticStatus_is_false() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( canShowDiagnosticStatus: false, attemptCount: 1 ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.CanShowProgress.Should().BeFalse(); }
public void Tutorial_should_have_sectionName() { // Given const string sectionName = "Section Name"; var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( sectionName: sectionName ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.SectionName.Should().Be(sectionName); }
public void Tutorial_should_not_recommend_a_tutorial_when_score_is_max() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( currentScore: 10, possibleScore: 10 ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.TutorialRecommendation.Should().Be("optional"); }
public void Tutorial_parses_supporting_materials_path(string?supportingMaterialPath) { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( supportingMaterialPath: supportingMaterialPath ); var expectedParsedPath = ContentUrlHelper.GetNullableContentPath(config, supportingMaterialPath); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.SupportingMaterialPath.Should().Be(expectedParsedPath); }
public void Tutorial_should_have_status() { // Given const string status = "Not started"; var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( status: status ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.Status.Should().Be(status); }