public void TaskExecutionItemTest_DeletionDate_Must_Be_In_History()
        {
            // Исполнение, которое создается при создании задачи
            var ex0 = new TaskExecutionItem(task, taskType.Object, taskExecutionState.Object, (byte)0, user.Object, true, currentDate, currentDate);

            // тестируемое исполнение
            execution = new TaskExecutionItem(task, taskType.Object, taskExecutionState.Object, (byte)0, user.Object, true, currentDate, currentDate);
            execution.SaveHistory(currentDate, user.Object);


            execution.DeletionDate = currentDate;
            execution.SaveHistory(currentDate, user.Object);

            Assert.AreEqual(2, execution.History.Count());
            var item = execution.History.ElementAt(1);

            Assert.AreEqual(true, item.IsDeletionDateChanged);
            Assert.AreEqual(currentDate, item.DeletionDate);

            Assert.AreEqual(false, item.IsCompletionPercentageChanged);
            Assert.AreEqual(false, item.IsDateChanged);
            Assert.AreEqual(false, item.IsTaskExecutionStateChanged);
            Assert.AreEqual(false, item.IsResultDescriptionChanged);
            Assert.AreEqual(false, item.IsSpentTimeChanged);
        }
        public void TaskExecutionItemTest_Init_Params_Must_Be_In_History()
        {
            execution = new TaskExecutionItem(task, taskType.Object, taskExecutionState.Object, (byte)0, user.Object, true, currentDate, currentDate.AddDays(1));
            execution.SaveHistory(currentDate, user.Object);

            Assert.AreEqual(1, execution.History.Count());
            var item = execution.History.ElementAt(0);

            Assert.AreEqual(1, item.CreatedBy.Id);
            Assert.AreEqual(currentDate, item.CreationDate);
            Assert.AreEqual(TaskHistoryItemType.TaskExecutionHistory, item.HistoryItemType);
            Assert.AreEqual(execution.Id, item.TaskExecutionItem.Id);
            Assert.AreEqual(task.Id, item.Task.Id);

            Assert.AreEqual(true, item.IsCompletionPercentageChanged);
            Assert.AreEqual((byte)0, item.CompletionPercentage);
            Assert.AreEqual(currentDate.AddDays(1), item.Date);
            Assert.AreEqual(true, item.IsDateChanged);
            Assert.AreEqual(true, item.IsDeletionDateChanged);
            Assert.AreEqual(null, item.DeletionDate);
            Assert.AreEqual(true, item.IsTaskExecutionStateChanged);
            Assert.AreEqual(executionStates[0].Id, item.TaskExecutionState.Id);
            Assert.AreEqual(true, item.IsResultDescriptionChanged);
            Assert.AreEqual(true, String.IsNullOrEmpty(item.ResultDescription));
            Assert.AreEqual(true, item.IsSpentTimeChanged);
            Assert.AreEqual(0, item.SpentTime);
        }
        public void TaskExecutionItemServiceTest_Histroy_Must_Be_Save()
        {
            var execution = new TaskExecutionItem(task.Object, taskType.Object, taskExecutionState, 42, user.Object, true, currentDate, currentDate);

            taskExecutionItemService.Save(execution, currentDate, user.Object);

            Assert.AreEqual(1, execution.History.Count());
        }
        public void TaskExecutionItemTest_Constructor_Param_Must_Be_Set()
        {
            execution = new TaskExecutionItem(task, taskType.Object, executionStates[0], (byte)0, user.Object, true, currentDate, currentDate.AddDays(1));

            Assert.AreEqual(task, execution.Task);
            Assert.AreEqual(user.Object, execution.CreatedBy);
            Assert.AreEqual(currentDate, execution.CreationDate);
            Assert.AreEqual(currentDate.AddDays(1), execution.Date);
        }
 public void TaskExecutionItemTest_Constructor_Must_Throw_Exception_On_NULL_Task()
 {
     try
     {
         execution = new TaskExecutionItem(null, taskType.Object, taskExecutionState.Object, (byte)0, user.Object, true, currentDate, currentDate.AddDays(1));
         Assert.Fail("Исключение не сгенерированно.");
     }
     catch (Exception ex)
     {
         Assert.AreEqual("Необходимо указать задачу, к которой относится исполнение.", ex.Message);
     }
 }
 public void TaskExecutionItemTest_Constructor_Must_Throw_Exception_On_NULL_CreatedBy()
 {
     try
     {
         execution = new TaskExecutionItem(task, taskType.Object, taskExecutionState.Object, (byte)0, null, true, currentDate, currentDate.AddDays(1));
         Assert.Fail("Исключение не сгенерированно.");
     }
     catch (Exception ex)
     {
         Assert.AreEqual("Необходимо указать пользователя, создавшего исполнение.", ex.Message);
     }
 }
        public void TaskTest_ExecutionState_And_StartDate_Must_Change()
        {
            execution = new TaskExecutionItem(task, taskType.Object, taskExecutionState.Object, (byte)0, user.Object, true, currentDate, currentDate);
            Assert.AreEqual(taskExecutionState.Object, task.ExecutionState);
            Assert.AreEqual((DateTime?)null, task.StartDate);

            var exDate = currentDate.AddDays(1);

            execution = new TaskExecutionItem(task, taskType.Object, taskExecutionState3.Object, (byte)0, user.Object, true, exDate, exDate);

            Assert.AreEqual(taskExecutionState3.Object, task.ExecutionState);
            Assert.AreEqual(exDate, task.StartDate);
        }
Beispiel #8
0
        /// <summary>
        /// Проверка возможности изменения даты исполнения задачи
        /// </summary>
        /// <param name="taskExecutionItem">Исполнение. Если NULL, то в качестве автора исполнения используется текущий пользователь.</param>
        /// <param name="user">Пользователь</param>
        public bool IsPossibilityToEditExecutionDate(TaskExecutionItem taskExecutionItem, User user)
        {
            try
            {
                CheckPossibilityToEditExecutionDate(taskExecutionItem, user);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public void TaskTest_CompletionPrecentage_Must_Be_Set()
        {
            execution = new TaskExecutionItem(task, taskType.Object, taskExecutionState.Object, (byte)0, user.Object, true, currentDate, currentDate);
            Assert.AreEqual(taskExecutionState.Object, task.ExecutionState);
            Assert.AreEqual((DateTime?)null, task.StartDate);

            var completionDate = currentDate.AddDays(1);

            execution = new TaskExecutionItem(task, taskType.Object, taskExecutionState3.Object, (byte)33, user.Object, true, completionDate, completionDate);

            Assert.AreEqual(completionDate, task.StartDate);
            Assert.AreEqual((DateTime?)null, task.FactualCompletionDate);
            Assert.AreEqual(33, task.CompletionPercentage);
        }
        public void TaskTest_SpentTime_Must_Increase()
        {
            execution = new TaskExecutionItem(task, taskType.Object, taskExecutionState.Object, (byte)0, user.Object, true, currentDate, currentDate);
            Assert.AreEqual(taskExecutionState.Object, task.ExecutionState);
            Assert.AreEqual((DateTime?)null, task.StartDate);

            var completionDate = currentDate.AddDays(1);

            execution           = new TaskExecutionItem(task, taskType.Object, taskExecutionState3.Object, (byte)0, user.Object, true, completionDate, completionDate);
            execution.SpentTime = 100;

            Assert.AreEqual(taskExecutionState3.Object, task.ExecutionState);
            Assert.AreEqual(completionDate, task.StartDate);
            Assert.AreEqual((DateTime?)null, task.FactualCompletionDate);
            Assert.AreEqual(100, task.FactualSpentTime);
        }
        public void TaskTest_Task_Must_Drop_CompletionDate()
        {
            execution = new TaskExecutionItem(task, taskType.Object, taskExecutionState.Object, (byte)0, user.Object, true, currentDate, currentDate);
            Assert.AreEqual(taskExecutionState.Object, task.ExecutionState);
            Assert.AreEqual((DateTime?)null, task.StartDate);

            var completionDate = currentDate.AddDays(1);

            execution = new TaskExecutionItem(task, taskType.Object, taskExecutionState4.Object, (byte)0, user.Object, true, completionDate, completionDate);

            var exDate = currentDate.AddDays(1);

            execution = new TaskExecutionItem(task, taskType.Object, taskExecutionState3.Object, (byte)0, user.Object, true, exDate, exDate);

            Assert.AreEqual(taskExecutionState3.Object, task.ExecutionState);
            Assert.AreEqual(completionDate, task.StartDate);
            Assert.AreEqual((DateTime?)null, task.FactualCompletionDate);
        }
        public void TaskExecutionItemTest_ResultDescription_Must_Be_In_History()
        {
            execution = new TaskExecutionItem(task, taskType.Object, taskExecutionState.Object, (byte)0, user.Object, true, currentDate, currentDate);
            execution.SaveHistory(currentDate, user.Object);

            execution.ResultDescription = "1234567890";
            execution.SaveHistory(currentDate, user.Object);

            Assert.AreEqual(2, execution.History.Count());
            var item = execution.History.ElementAt(1);

            Assert.AreEqual(true, item.IsResultDescriptionChanged);
            Assert.AreEqual("1234567890", item.ResultDescription);

            Assert.AreEqual(false, item.IsCompletionPercentageChanged);
            Assert.AreEqual(false, item.IsDateChanged);
            Assert.AreEqual(false, item.IsDeletionDateChanged);
            Assert.AreEqual(false, item.IsTaskExecutionStateChanged);
            Assert.AreEqual(false, item.IsSpentTimeChanged);
        }
Beispiel #13
0
        /// <summary>
        /// Сохранение исполнения
        /// </summary>
        /// <param name="taskExecutionItem">Исполнение</param>
        /// <param name="user">Пользователь, сохраняющий исполнение</param>
        /// <returns>Идентификатор сохраненного исполнения</returns>
        public int Save(TaskExecutionItem taskExecutionItem, DateTime currentDate, User user)
        {
            if (taskExecutionItem.Id == 0)             // Если исполнение сохраняется, то
            {
                if (taskExecutionItem.IsCreatedByUser) //Если исполнение создано пользователем, то
                {
                    // проверяем право на создание
                    CheckPossibilityToCreateTaskExecution(taskExecutionItem.Task, user);
                }// иначе право на редактирование задачи уже проверено презентером
            }
            else
            {
                // Иначе на редактирование
                CheckPossibilityToEditTaskExecution(taskExecutionItem, user);
            }

            taskExecutionItemRepository.Save(taskExecutionItem);
            taskExecutionItem.SaveHistory(currentDate, user);   //Сохраняем историю

            return(taskExecutionItem.Id);
        }
Beispiel #14
0
        public void TaskTest_Execution_Must_Be_Save()
        {
            var task = new Task(topic, taskType, taskPriority, state1, currentDate, user.Object);
            var ex0  = new TaskExecutionItem(task, task.Type, state1, task.CompletionPercentage, user.Object, false, currentDate, currentDate);

            task.SaveHistory(currentDate, user.Object);

            var newCurrentDate = currentDate.AddDays(1);
            var execution      = new TaskExecutionItem(task, task.Type, state3, completionPercentage2, user.Object, true, newCurrentDate, newCurrentDate);

            execution.SpentTime = 100;
            execution.SaveHistory(newCurrentDate, user.Object);
            task.SaveHistory(newCurrentDate, user.Object);

            Assert.AreEqual(2, task.History.Count());
            var item = task.History.ElementAt(1);

            Assert.AreEqual(false, item.IsContractorChanged);
            Assert.AreEqual(false, item.IsDeadLineChanged);
            Assert.AreEqual(false, item.IsDealChanged);
            Assert.AreEqual(false, item.IsDeletionDateChanged);
            Assert.AreEqual(false, item.IsDescriptionChanged);
            Assert.AreEqual(false, item.IsExecutedByChanged);
            Assert.AreEqual(true, item.IsTaskExecutionStateChanged);
            Assert.AreEqual(true, item.IsFactualCompletionDateChanged);
            Assert.AreEqual(true, item.IsFactualSpentTimeChanged);
            Assert.AreEqual(false, item.IsTaskPriorityChanged);
            Assert.AreEqual(false, item.IsProductionOrderChanged);
            Assert.AreEqual(true, item.IsStartDateChanged);
            Assert.AreEqual(false, item.IsTopicChanged);
            Assert.AreEqual(false, item.IsTaskTypeChanged);

            Assert.AreEqual(state3, task.ExecutionState);
            Assert.AreEqual(newCurrentDate, task.StartDate);
            Assert.AreEqual(100, task.FactualSpentTime);
            Assert.AreEqual(newCurrentDate, task.FactualCompletionDate);
        }
 public void Delete(TaskExecutionItem entity)
 {
     CurrentSession.SaveOrUpdate(entity);
 }
Beispiel #16
0
 /// <summary>
 /// Проверка права на удаление исполнения задачи
 /// </summary>
 /// <param name="taskExecutionItem">Исполнение задачи</param>
 /// <param name="user">Пользователь</param>
 public void CheckPossibilityToDeleteTaskExecution(TaskExecutionItem taskExecutionItem, User user)
 {
     CheckTaskOnPossibilityToEditTaskExecution(taskExecutionItem.Task, user);
     CheckPermissionToPerformOperation(taskExecutionItem.CreatedBy, user, Permission.TaskExecutionItem_Delete);
 }
Beispiel #17
0
 /// <summary>
 /// Удаление исполнения
 /// </summary>
 /// <param name="taskExecutionItem">Исполнение</param>
 /// <param name="currentDate">Текущая дата</param>
 /// <param name="user">Пользователь, удаляющий исполнение</param>
 public void Delete(TaskExecutionItem taskExecutionItem, DateTime currentDate, User user)
 {
     taskExecutionItem.DeletionDate = currentDate;
     taskExecutionItemRepository.Delete(taskExecutionItem);
     taskExecutionItem.SaveHistory(currentDate, user);    //Сохраняем историю изменений исполнения
 }
Beispiel #18
0
 /// <summary>
 /// Проверка возможности изменения даты исполнения задачи
 /// </summary>
 /// <param name="taskExecutionItem">Исполнение. Если NULL, то в качестве автора исполнения используется текущий пользователь.</param>
 /// <param name="user">Пользователь</param>
 public void CheckPossibilityToEditExecutionDate(TaskExecutionItem taskExecutionItem, User user)
 {
     CheckPermissionToPerformOperation(taskExecutionItem != null ? taskExecutionItem.CreatedBy : user, user, Permission.TaskExecutionItem_EditExecutionDate);
 }