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 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); }
/// <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); }
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); }
/// <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); //Сохраняем историю изменений исполнения }