public void ShouldInstantiateNewWorkItemDto() { // act WorkItemDto workItemDto = new WorkItemDto(WORK_ITEM_ID, WORK_ITEM_TITLE, COMMENT_CONTENT0, m_commentDateTime0); // assert Assert.AreEqual(WORK_ITEM_ID, workItemDto.Id); Assert.AreEqual(WORK_ITEM_TITLE, workItemDto.Title); Assert.AreEqual(COMMENT_CONTENT0, workItemDto.Comment); Assert.AreEqual(m_commentDateTime0, workItemDto.Time); }
/// <summary> /// Write work items data to specified file. /// </summary> public void Write(string filePath, WorkItemDto singleWorkItemData) { var file = new FileInfo(filePath); if (!file.Exists) { CreateOutputFile(filePath); } var allWorkItemsData = _reportFileReader.ReadAllItems(filePath); var workItem = FindWorkItem(singleWorkItemData, allWorkItemsData); if (workItem == null) { Log.Instance.Info("Writing new item to the file"); var newWorkItem = new WorkItem(singleWorkItemData.Id, singleWorkItemData.Title, singleWorkItemData.Time, singleWorkItemData.Comment); allWorkItemsData.Add(newWorkItem); //update end time of previous work item when adding new one. UpdatePreviousItemEndTime(singleWorkItemData.Time, allWorkItemsData); } else { Log.Instance.Info("Updating existing item"); if (workItem.LastComment.CompareTo(singleWorkItemData.Comment) == 0) { workItem.LastComment.SetEndTime(singleWorkItemData.Time); } else { workItem.AddComment(singleWorkItemData.Comment, singleWorkItemData.Time); } } UpdateReportFile(filePath, allWorkItemsData); }
/// <summary> /// Search in list for item with the same id and title as specified one. /// Returns null if does not find matching item. /// </summary> private WorkItem FindWorkItem(WorkItemDto item, WorkItemsList allItems) { var workItem = allItems.Find(wi => wi.Id == item.Id && wi.Title == item.Title); return workItem; }
public SaveReportEventArgs(WorkItemDto wiData) { WorkItemData = wiData; }
/// <summary> /// Writes work item data. /// </summary> public void Write(WorkItemDto workItemData) { _writer.Write(_filePath, workItemData); }
/// <summary> /// Updates main view (form) with work item data. /// </summary> public void UpdateView(WorkItemDto workItem) { _mainViewController.UpdateWorkItemData(workItem); }