public void CheckProgressForCompletion_does_not_call_data_services_if_completionStatus_is_zero_or_less( int completionStatus ) { // Given var detailedCourseProgress = ProgressTestHelper.GetDefaultDetailedCourseProgress(); A.CallTo(() => progressDataService.GetCompletionStatusForProgress(detailedCourseProgress.ProgressId)) .Returns(completionStatus); // When progressService.CheckProgressForCompletionAndSendEmailIfCompleted(detailedCourseProgress); // Then A.CallTo( () => progressDataService.SetCompletionDate( A <int> ._, A <DateTime> ._ ) ).MustNotHaveHappened(); A.CallTo( () => learningLogItemsDataService.MarkLearningLogItemsCompleteByProgressId( A <int> ._ ) ).MustNotHaveHappened(); A.CallTo( () => notificationService.SendProgressCompletionNotificationEmail( A <DetailedCourseProgress> ._, A <int> ._, A <int> ._ ) ).MustNotHaveHappened(); }
public void CheckProgressForCompletion_does_nothing_if_progress_is_already_completed() { // Given var completedDate = new DateTime(2022, 1, 1, 1, 1, 1); var detailedCourseProgress = ProgressTestHelper.GetDefaultDetailedCourseProgress(completed: completedDate); // When progressService.CheckProgressForCompletionAndSendEmailIfCompleted(detailedCourseProgress); // Then A.CallTo( () => progressDataService.GetCompletionStatusForProgress(A <int> ._) ).MustNotHaveHappened(); }
public void SendProgressCompletionNotification_does_not_send_email_if_delegate_email_is_null() { // Given var progress = ProgressTestHelper.GetDefaultDetailedCourseProgress(delegateEmail: null); SetUpSendProgressCompletionNotificationEmailFakes(); // When notificationService.SendProgressCompletionNotificationEmail(progress, 2, 3); // Then A.CallTo(() => emailService.SendEmail(A <Email> ._)) .MustNotHaveHappened(); }
public void SendProgressCompletionNotification_does_not_send_email_if_progress_completion_data_is_null() { // Given var progress = ProgressTestHelper.GetDefaultDetailedCourseProgress(); A.CallTo(() => notificationDataService.GetProgressCompletionData(ProgressId, DelegateId, CustomisationId)) .Returns(null); // When notificationService.SendProgressCompletionNotificationEmail(progress, 2, 3); // Then A.CallTo(() => emailService.SendEmail(A <Email> ._)) .MustNotHaveHappened(); }
CheckProgressForCompletion_calls_data_services_with_correct_values_if_completionStatus_is_greater_than_zero() { // Given var detailedCourseProgress = ProgressTestHelper.GetDefaultDetailedCourseProgress(); var numLearningLogItemsAffected = 3; A.CallTo(() => progressDataService.GetCompletionStatusForProgress(detailedCourseProgress.ProgressId)) .Returns(1); A.CallTo( () => progressDataService.SetCompletionDate( A <int> ._, A <DateTime> ._ ) ).DoesNothing(); A.CallTo( () => learningLogItemsDataService.MarkLearningLogItemsCompleteByProgressId( A <int> ._ ) ).Returns(numLearningLogItemsAffected); A.CallTo( () => notificationService.SendProgressCompletionNotificationEmail( A <DetailedCourseProgress> ._, A <int> ._, A <int> ._ ) ).DoesNothing(); // When progressService.CheckProgressForCompletionAndSendEmailIfCompleted(detailedCourseProgress); // Then A.CallTo(() => progressDataService.GetCompletionStatusForProgress(detailedCourseProgress.ProgressId)) .MustHaveHappenedOnceExactly(); A.CallTo(() => progressDataService.SetCompletionDate(A <int> ._, A <DateTime> ._)) .MustHaveHappenedOnceExactly(); A.CallTo(() => learningLogItemsDataService.MarkLearningLogItemsCompleteByProgressId(A <int> ._)) .MustHaveHappenedOnceExactly(); A.CallTo( () => notificationService.SendProgressCompletionNotificationEmail( A <DetailedCourseProgress> ._, A <int> ._, A <int> ._ ) ).MustHaveHappenedOnceExactly(); }
public void SendProgressCompletionNotification_calls_data_service_and_sends_email_to_correct_delegate_email() { // Given var progress = ProgressTestHelper.GetDefaultDetailedCourseProgress(); SetUpSendProgressCompletionNotificationEmailFakes(); // When notificationService.SendProgressCompletionNotificationEmail(progress, 2, 3); // Then A.CallTo(() => notificationDataService.GetProgressCompletionData(ProgressId, DelegateId, CustomisationId)) .MustHaveHappenedOnceExactly(); A.CallTo( () => emailService.SendEmail( A <Email> .That.Matches( e => e.To.SequenceEqual(new[] { progress.DelegateEmail }) ) ) ).MustHaveHappenedOnceExactly(); }
public void SendProgressCompletionNotification_does_not_add_line_of_text_about_admin_if_admin_email_is_null() { // Given var progress = ProgressTestHelper.GetDefaultDetailedCourseProgress(); SetUpSendProgressCompletionNotificationEmailFakes(adminEmail: null); // When notificationService.SendProgressCompletionNotificationEmail(progress, 2, 3); // Then A.CallTo( () => emailService.SendEmail( A <Email> .That.Matches( e => e.Body.TextBody.Contains( "Note: This message has been copied to the administrator(s) managing this activity, for their information." ) ) ) ).MustNotHaveHappened(); }
public void SendProgressCompletionNotification_ccs_admin_if_email_found() { // Given const string adminEmail = "*****@*****.**"; var progress = ProgressTestHelper.GetDefaultDetailedCourseProgress(); SetUpSendProgressCompletionNotificationEmailFakes(adminEmail: adminEmail); // When notificationService.SendProgressCompletionNotificationEmail(progress, 2, 3); // Then A.CallTo( () => emailService.SendEmail( A <Email> .That.Matches( e => e.Cc.SequenceEqual(new[] { adminEmail }) && e.Body.TextBody.Contains( "Note: This message has been copied to the administrator(s) managing this activity, for their information." ) ) ) ).MustHaveHappenedOnceExactly(); }
SendProgressCompletionNotification_does_not_add_the_extra_learning_log_item_line_of_text_when_number_affected_is_zero( string lineOfText ) { // Given var progress = ProgressTestHelper.GetDefaultDetailedCourseProgress(); SetUpSendProgressCompletionNotificationEmailFakes(); // When notificationService.SendProgressCompletionNotificationEmail(progress, 2, 0); // Then A.CallTo( () => emailService.SendEmail( A <Email> .That.Matches( e => e.Body.TextBody.Contains( lineOfText ) ) ) ).MustNotHaveHappened(); }
public void SendProgressCompletionNotification_forms_url_correctly() { // Given const string finaliseUrl = "/tracking/finalise?SessionID=123&ProgressID=1&UserCentreID=101"; var progress = ProgressTestHelper.GetDefaultDetailedCourseProgress(); SetUpSendProgressCompletionNotificationEmailFakes(); // When notificationService.SendProgressCompletionNotificationEmail(progress, 2, 3); // Then A.CallTo( () => emailService.SendEmail( A <Email> .That.Matches( e => e.Body.HtmlBody.Contains( finaliseUrl ) ) ) ).MustHaveHappenedOnceExactly(); }
public void SendProgressCompletionNotification_shows_correct_text_for_number_of_learning_log_items_affected( int numLearningLogItemsAffected, string lineOfText ) { // Given var progress = ProgressTestHelper.GetDefaultDetailedCourseProgress(); SetUpSendProgressCompletionNotificationEmailFakes(); // When notificationService.SendProgressCompletionNotificationEmail(progress, 2, numLearningLogItemsAffected); // Then A.CallTo( () => emailService.SendEmail( A <Email> .That.Matches( e => e.Body.TextBody.Contains( lineOfText ) ) ) ).MustHaveHappenedOnceExactly(); }
public void SendProgressCompletionNotification_shows_correct_text_for_completion_status( int completionStatus, string lineOfText ) { // Given var progress = ProgressTestHelper.GetDefaultDetailedCourseProgress(); SetUpSendProgressCompletionNotificationEmailFakes(); // When notificationService.SendProgressCompletionNotificationEmail(progress, completionStatus, 3); // Then A.CallTo( () => emailService.SendEmail( A <Email> .That.Matches( e => e.Body.TextBody.Contains( lineOfText ) ) ) ).MustHaveHappenedOnceExactly(); }