Пример #1
0
        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 CheckProgressForCompletionAndSendEmailIfCompleted(DelegateCourseInfo progress)
        {
            if (progress.Completed != null)
            {
                return;
            }

            var completionStatus = progressDataService.GetCompletionStatusForProgress(progress.ProgressId);

            if (completionStatus > 0)
            {
                progressDataService.SetCompletionDate(progress.ProgressId, DateTime.UtcNow);
                var numLearningLogItemsAffected =
                    learningLogItemsDataService.MarkLearningLogItemsCompleteByProgressId(progress.ProgressId);
                notificationService.SendProgressCompletionNotificationEmail(
                    progress,
                    completionStatus,
                    numLearningLogItemsAffected
                    );
            }
        }