public RiskAssessmentReviewTaskDto MapWithAssignedToAndReview(RiskAssessmentReviewTask entity)
        {
            var dto = new TaskDtoMapper().MapWithAssignedTo(entity) as RiskAssessmentReviewTaskDto;

            dto.RiskAssessmentReview =
                new RiskAssessmentReviewDtoMapper().Map(entity.RiskAssessmentReview);

            return dto;
        }
Ejemplo n.º 2
0
        public void When_MarkAsDeleted_review_task_already_completed_Then_should_throw_correct_exception()
        {
            //Given
            var task = new RiskAssessmentReviewTask();
            var user = new UserForAuditing();

            //When
            //Then
            Assert.Throws<AttemptingToDeleteRiskAssessmentReviewTaskException>(() => task.MarkForDelete(user));
        }
        public void Given_task_SendTaskCompletedNotification_is_false_When_IsTaskCompletedNotificationRequired_Then_return_false()
        {
            // Given
            reviewTask = new RiskAssessmentReviewTask() { RiskAssessmentReview = _review.Object, SendTaskCompletedNotification = false };

            // When
            var result = reviewTask.IsTaskCompletedNotificationRequired();

            // Then
            Assert.IsFalse(result);
        }
        public void Given_task_has_all_requirements_When_IsTaskCompletedNotificationRequired_Then_return_true()
        {
            // Given
            reviewTask = new RiskAssessmentReviewTask() { RiskAssessmentReview = _review.Object, SendTaskCompletedNotification = true };

            // When
            var result = reviewTask.IsTaskCompletedNotificationRequired();

            // Then
            Assert.IsTrue(result);
        }
        public void When_MarkAsNoLongerRequired_review_task_already_completed_Then_should_throw_correct_exception()
        {
            //Given
            var task = new RiskAssessmentReviewTask
                           {TaskCompletedDate = new DateTime(), TaskStatus = TaskStatus.NoLongerRequired};
            var user = new UserForAuditing();

            //When
            //Then
            Assert.Throws<AttemptingToMarkAsNoLongerRequiredRiskAssessmentReviewTaskThatIsNoLongerRequiredException>(() => task.MarkAsNoLongerRequired(user));
        }
        public void Given_tasks_RiskAssessor_does_not_have_contact_details_is_false_When_IsTaskCompletedNotificationRequired_Then_return_false()
        {
            // Given
            _riskAssessorEmployee.Setup(x => x.MainContactDetails);
            reviewTask = new RiskAssessmentReviewTask() { RiskAssessmentReview = _review.Object, SendTaskCompletedNotification = true };

            // When
            var result = reviewTask.IsTaskCompletedNotificationRequired();

            // Then
            Assert.IsFalse(result);
        }
        private static bool DoesTaskNeedToBeNotified(RiskAssessmentReviewTask task)
        {            
            var notificationType = task.RiskAssessmentReview.RiskAssessment.RiskAssessor.Employee.NotificationType;
            var notificationFrequency = task.RiskAssessmentReview.RiskAssessment.RiskAssessor.Employee.NotificationFrequecy;


            return (notificationType == NotificationType.Daily) ||
                   (notificationType == NotificationType.Weekly && task.TaskCompletedDate.HasValue && task.TaskCompletedDate.Value > DateTime.Now.AddDays(-7))
                   || (notificationType == NotificationType.Monthly && notificationFrequency.HasValue && task.TaskCompletedDate.HasValue &&
                       task.TaskCompletedDate.Value > QueriesHelper.GetPreviousMonthsDate(notificationFrequency.Value));

        }
Ejemplo n.º 8
0
        public void When_complete_review_task_already_completed_Then_should_throw_correct_exception()
        {
            //Given
            var task = new RiskAssessmentReviewTask();
            task.TaskCompletedDate = new DateTime();
            task.TaskStatus = TaskStatus.Completed;
            var userForAuditing = new UserForAuditing();
            var user = new User();

            //When
            //Then
            Assert.Throws<AttemptingToCompleteTaskThatIsCompletedException>(() => task.Complete("comments", null, new List<long>(), userForAuditing, user));
        }
Ejemplo n.º 9
0
        public void When_complete_Then_should_set_task_completed_by_to_completing_user()
        {
            //Given
            var userForAuditing = new UserForAuditing();
            var employee = new Employee();
            var user = new User{ Employee = employee };
            var task = new RiskAssessmentReviewTask() { TaskAssignedTo = employee };

            //When
            task.Complete("comments", new List<CreateDocumentParameters>(), new List<long>(), userForAuditing, user);

            //Then
            Assert.That(task.TaskCompletedBy, Is.EqualTo(userForAuditing));
        }
        public void When_MarkAsNoLongerRequired_Then_should_set_properties_correctly()
        {
            //Given
            var user = new User() { Employee = new Employee()};
            var task = new RiskAssessmentReviewTask() { TaskAssignedTo = user.Employee };

            //When
            task.MarkAsNoLongerRequired(new UserForAuditing()
                                            {
                                                Id = user.Id
                                            });

            //Then
            Assert.That(task.LastModifiedOn.Value.Date, Is.EqualTo(DateTime.Today));
            Assert.That(task.LastModifiedBy.Id, Is.EqualTo(user.Id));
            Assert.That(task.TaskStatus, Is.EqualTo(TaskStatus.NoLongerRequired));
        }
Ejemplo n.º 11
0
        public void Given_a_task_is_assigned_to_userA_When_it_is_completed_by_userB_Then_the_tasks_status_is_set_to_no_longer_required()
        {
            // Given
            var task = new RiskAssessmentReviewTask();
            var employee = new Employee() { Id = Guid.NewGuid() };
            var userA = new User() { Employee = employee };
            var userBForAuditing = new UserForAuditing() { Id = Guid.NewGuid() };
            var userB = new User() { Employee = new Employee() { Id = Guid.NewGuid() } };
            

            // When
            task.TaskAssignedTo = userA.Employee;
            task.Complete(It.IsAny<string>(), new List<CreateDocumentParameters>(), new List<long>(), userBForAuditing, userB);

            //
            Assert.That(task.TaskAssignedTo, Is.EqualTo(userA.Employee));
            Assert.That(task.TaskStatus, Is.EqualTo(TaskStatus.NoLongerRequired));
        }
        public static new RiskAssessmentReviewTask Create(
            string reference,
            string title,
            string description,
            DateTime? taskCompletionDueDate,
            TaskStatus taskStatus,
            Employee assignedTo,
            UserForAuditing user,
            IEnumerable<CreateDocumentParameters> createDocumentParameterObjects,
            TaskCategory taskCategory,
            int taskReoccurringTypeId,
            DateTime? taskReoccurringEndDate,
            RiskAssessmentReview riskAssessmentReview,
            bool sendTaskNotification,
            bool sendTaskCompletedNotification,
            bool sendTaskOverdueNotification,
            bool sendTaskDueTomorrowNotification,
            Guid taskGuid
            )
        {
            var riskAssessmentReviewTask = new RiskAssessmentReviewTask();

            riskAssessmentReviewTask.SetValuesForCreate(
                reference,
                title,
                description,
                taskCompletionDueDate,
                taskStatus,
                assignedTo,
                user,
                createDocumentParameterObjects,
                taskCategory,
                taskReoccurringTypeId,
                taskReoccurringEndDate,
                sendTaskNotification,
                sendTaskCompletedNotification,
                sendTaskOverdueNotification,
                sendTaskDueTomorrowNotification,
                taskGuid,null);

            riskAssessmentReviewTask.RiskAssessmentReview = riskAssessmentReview;

            return riskAssessmentReviewTask;
        }
Ejemplo n.º 13
0
        public void When_complete_Then_should_set_properties_correctly()
        {
            //Given
            var userForAuditing = new UserForAuditing();
            var employee = new Employee();
            var user = new User{ Employee = employee };
            var task = new RiskAssessmentReviewTask() { TaskAssignedTo = employee };

            //When
            task.Complete("comments", new List<CreateDocumentParameters>(), new List<long>(), userForAuditing, user);

            //Then
            Assert.That(task.LastModifiedOn.Value.Date, Is.EqualTo(DateTime.Today));
            Assert.That(task.LastModifiedBy, Is.EqualTo(userForAuditing));
            Assert.That(task.TaskCompletedComments, Is.EqualTo("comments"));
            Assert.That(task.TaskCompletedDate.Value.Date, Is.EqualTo(DateTime.Today.Date));
            Assert.That(task.LastModifiedBy, Is.EqualTo(userForAuditing));
            Assert.That(task.TaskStatus, Is.EqualTo(TaskStatus.Completed));
        }
        public void Given_tasks_RiskAssessor_email_is_empty_string_When_IsTaskCompletedNotificationRequired_Then_return_false()
        {
            // Given
            _riskAssessorEmployee.Setup(x => x.MainContactDetails.Email).Returns(string.Empty);
            reviewTask = new RiskAssessmentReviewTask() { RiskAssessmentReview = _review.Object, SendTaskCompletedNotification = true };

            // When
            var result = reviewTask.IsTaskCompletedNotificationRequired();

            // Then
            Assert.IsFalse(result);
        }