public void SetUp() { _emailSender = new Mock<IEmailSender>(); _userRepository = new Mock<IUserRepository>(); _taskRepository = new Mock<ITasksRepository>(); _urlConfiguration = new Mock<IBusinessSafeEmailLinkBaseUrlConfiguration>(); _urlConfiguration.Setup(x => x.GetBaseUrl()).Returns(string.Empty); _userRepository.Setup(x => x.GetById(It.IsAny<Guid>())).Returns(new User() { Employee = new Employee() { ContactDetails = new List<EmployeeContactDetail>() { new EmployeeContactDetail() {Email = "*****@*****.**"}} } }); _action = new BusinessSafe.Domain.Entities.Action() { ActionPlan = new ActionPlan(), ActionPlanId = 1, Id = 1, Category = ActionCategory.Action, ActionRequired = "You required this action", }; _task = new ActionTask() { TaskAssignedTo = new Employee { ContactDetails = new List<EmployeeContactDetail>() { new EmployeeContactDetail() { Email = "*****@*****.**" } } }, CreatedBy = new UserForAuditing() { Id = Guid.NewGuid(), }, Title = "Action task title", Reference = "Action task reference", Action = _action, }; }
private static bool IsTaskDue(ActionTask task) { return ( (task.TaskAssignedTo.NotificationType == NotificationType.Daily && task.TaskCompletionDueDate.HasValue && QueriesHelper.SimplifyDate(task.TaskCompletionDueDate.Value) == QueriesHelper.SimplifyDate(DateTime.Now.AddDays(1))) || (task.TaskAssignedTo.NotificationType == NotificationType.Weekly && task.TaskCompletionDueDate.HasValue && task.TaskCompletionDueDate.Value < DateTime.Now.AddDays(7)) || (task.TaskAssignedTo.NotificationType == NotificationType.Monthly && task.TaskCompletionDueDate.HasValue && task.TaskCompletionDueDate.Value < DateTime.Now.AddDays(30)) ); }
public ActionTaskDto MapWithAssignedTo(ActionTask entity) { var dto = new ActionTaskDto(); dto = PopulateTaskDto(entity, dto) as ActionTaskDto; dto.Action = entity.Action != null ? new ActionDtoMapper().Map(entity.Action) : null; return dto; }
public static ActionTask Create(string reference, string title, string description, DateTime? taskCompletionDueDate, TaskStatus taskStatus, Employee assignedTo, UserForAuditing user, IEnumerable<CreateDocumentParameters> createDocumentParameterObjects, TaskCategory taskCategory, int taskReoccurringTypeId, DateTime? taskReoccurringEndDate, bool sendTaskNotification, bool sendTaskCompletedNotification, bool sendTaskOverdueNotification, bool sendTaskDueTomorrowNotification, Guid taskGuid, Site site, Action action) { var task = new ActionTask(); task.SetValuesForCreate( reference, title, description, taskCompletionDueDate, taskStatus, assignedTo, user, createDocumentParameterObjects, taskCategory, taskReoccurringTypeId, taskReoccurringEndDate, sendTaskNotification, sendTaskCompletedNotification, sendTaskOverdueNotification, sendTaskDueTomorrowNotification, taskGuid, site); task.Action = action; action.AddTask(task); action.SetLastModifiedBy(user); return task; }
private static bool DoesTaskNeedToBeNotified(ActionTask task, Guid employeeId) { // Risk Assessor if (task.TaskAssignedTo != null && task.TaskAssignedTo.Id == employeeId) { var notificationType = task.TaskAssignedTo.NotificationType; var notificationFrequency = task.TaskAssignedTo.NotificationFrequecy; return (notificationType == NotificationType.Daily || (notificationType == NotificationType.Weekly && task.TaskCompletionDueDate.HasValue && QueriesHelper.SimplifyDate(task.TaskCompletionDueDate.Value) >= QueriesHelper.SimplifyDate(DateTime.Now.AddDays(-7))) || (notificationType == NotificationType.Monthly && notificationFrequency.HasValue && task.TaskCompletionDueDate.HasValue && task.TaskCompletionDueDate.Value >= QueriesHelper.GetPreviousMonthsDate(notificationFrequency.Value))); } else { return false; } }
public void Given_Employee_is_assigned_a_task_then_return_task() { var employee = new Employee() { Id = Guid.NewGuid(), NotificationType = NotificationType.Daily}; var actionTask = new ActionTask() { TaskAssignedTo = employee, TaskCompletedDate = null, TaskCompletionDueDate = DateTime.Now.AddDays(-5) }; var action = new BusinessSafe.Domain.Entities.Action(); action.ActionTasks.Add(actionTask); _actions.Add(action); var target = new GetOverdueActionTasksForEmployeeQuery(_queryableWrapper.Object); //WHEN var result = target.Execute(employee.Id, null); //THEN Assert.That(result.Count, Is.EqualTo(1)); }
public void Given_Employee_is_assignee_then_dont_return_due_2days_action_task_when_set_to_daily_notifications() { var employee = new Employee() { Id = Guid.NewGuid(), NotificationType = NotificationType.Daily }; var actionTask = new ActionTask() { TaskAssignedTo = employee, TaskStatus = TaskStatus.Outstanding, TaskCompletedDate = null, TaskCompletionDueDate = DateTime.Now.AddDays(2) }; var action = new Domain.Entities.Action(); action.ActionTasks.Add(actionTask); _actions.Add(action); var target = new GetDueActionTasksForEmployeeQuery(_queryableWrapper.Object); //WHEN var result = target.Execute(employee.Id, null); //THEN Assert.That(result.Count, Is.EqualTo(0)); }
public void given_only_deleted_tasks_when_get_status_from_tasks_then_return_none() { // Given var plan = new ActionPlan(); plan.Actions = new List<Action>(); var actionTask = new ActionTask() { Deleted = true, TaskStatus = TaskStatus.Outstanding, TaskCompletionDueDate = DateTime.Now }; plan.Actions.Add(new Action{ActionTasks = new List<ActionTask>{actionTask}}); // When var result = plan.GetStatusFromActions(); // Then Assert.That(result, Is.EqualTo(DerivedTaskStatusForDisplay.None)); }
private ActionTask CreateActionTask() { ActionTask task = new ActionTask(); return task; }
public void Given_notification_is_weekly_and_taskDueDate_less_than_month_away_then_return_due_action_task() { var employee = new Employee() { Id = Guid.NewGuid(), NotificationType = NotificationType.Monthly }; var actionTask = new ActionTask() { TaskAssignedTo = employee, TaskStatus = TaskStatus.Outstanding, TaskCompletedDate = null, TaskCompletionDueDate = DateTime.Now.AddDays(25) }; var action = new Domain.Entities.Action(); action.ActionTasks.Add(actionTask); _actions.Add(action); var target = new GetDueActionTasksForEmployeeQuery(_queryableWrapper.Object); //WHEN var result = target.Execute(employee.Id, null); //THEN Assert.That(result.Count, Is.EqualTo(1)); }
private void UpdateActionTask(AssignActionTaskRequest request, Employee employee, UserForAuditing user, TaskCategory taskCategory, Action action, Site site) { var createDocumentParameterObjects = request.Documents == null ? null : _documentParameterHelper.GetCreateDocumentParameters(request.Documents, request.CompanyId); if (action.ActionTasks.Any()) { var task = action.ActionTasks.FirstOrDefault(); task.Update(action.AreaOfNonCompliance, action.ActionRequired, request.DueDate, TaskStatus.Outstanding, employee, user, createDocumentParameterObjects, taskCategory, (int) TaskReoccurringType.None, null, request.SendTaskNotification, request.SendTaskCompletedNotification, request.SendTaskOverdueNotification, request.SendTaskDueTomorrowNotification, task.TaskGuid, site ); } else { var task = new ActionTask(); task = ActionTask.Create( action.Reference, action.AreaOfNonCompliance, action.ActionRequired, request.DueDate, TaskStatus.Outstanding, employee, user, createDocumentParameterObjects, taskCategory, (int) TaskReoccurringType.None, null, request.SendTaskNotification, request.SendTaskCompletedNotification, request.SendTaskOverdueNotification, request.SendTaskDueTomorrowNotification, Guid.NewGuid(), site, action ); } }