public void ShouldNotContainAnyWorkItems() { //arrange const int EXP_COUNT = 0; //act WorkItemsList itemsList = new WorkItemsList(); //assert Assert.AreEqual(EXP_COUNT, itemsList.Count); }
public void ShouldIncrementItemsCount() { //arrange const int EXP_COUNT = 1; WorkItem item = new WorkItem(1, "title", null); WorkItemsList itemsList = new WorkItemsList(); //act itemsList.Add(item); //assert Assert.AreEqual(EXP_COUNT, itemsList.Count); }
public void ShouldReturnEmptyWorkItem() { //arrange WorkItemsList itemsList = new WorkItemsList(); int INDEX = 0; //act WorkItem result = itemsList[INDEX]; //assert Assert.AreEqual(0, result.Id); Assert.AreEqual(string.Empty, result.Title); Assert.AreEqual(string.Empty, result.Comments[0].Title); }
public void ShouldAddBothItems() { //arrange const int EXP_COUNT = 2; WorkItem firstItem = new WorkItem(1, "title", null); WorkItem secondItem = new WorkItem(2, "title", null); WorkItemsList itemsList = new WorkItemsList(); //act itemsList.Add(firstItem); itemsList.Add(secondItem); //assert Assert.AreEqual(EXP_COUNT, itemsList.Count); }
/// <summary> /// Update file, using data of all existing work items. /// </summary> private static void UpdateReportFile(string filePath, WorkItemsList workItemsData) { var workItemsDocument = new XDocument( new XElement(XmlElements.WorkItems.ToString(), from workItem in workItemsData select new XElement( XmlElements.WorkItem, new XElement(XmlElements.Id, workItem.Id), new XElement(XmlElements.Title, workItem.Title), from comment in workItem.Comments select new XElement(XmlElements.Comment, new XAttribute(XmlElements.StartTime, comment.StartTime), new XAttribute(XmlElements.EndTime, comment.EndTime), comment.Title ) ) ) ); workItemsDocument.Save(filePath); }
/// <summary> /// Reads work items data from specified file. /// </summary> public WorkItemsList ReadAllItems(string filePath) { IEnumerable<WorkItem> fileData = new List<WorkItem>(); var file = new FileInfo(filePath); if (file.Exists) { XDocument workItemsDocument = XDocument.Load(filePath); if (workItemsDocument != null) { try { fileData = ( from workItem in workItemsDocument.Root.Elements(XmlElements.WorkItem) select new WorkItem ( int.Parse(workItem.Element(XmlElements.Id).Value), workItem.Element(XmlElements.Title).Value, //reads a list of comments (from comment in workItem.Elements(XmlElements.Comment) select new WorkItemComment( comment.Value, DateTime.Parse(comment.Attribute(XmlElements.StartTime).Value), DateTime.Parse(comment.Attribute(XmlElements.EndTime).Value) )).ToList<WorkItemComment>() ) ).ToList<WorkItem>(); } catch(Exception e) { Log.Instance.Error("Reading file unsuccessful"+e.Message); } } } WorkItemsList workItemsData = new WorkItemsList(fileData); Log.Instance.Info(string.Format("Loaded {0} items", workItemsData.Count)); return workItemsData; }
/// <summary> /// Updates end time of previous work item. /// </summary> private static void UpdatePreviousItemEndTime(DateTime time, WorkItemsList allWorkItemsData) { allWorkItemsData.LastItem.LastComment.SetEndTime(time); }
/// <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 void ShouldReturnEmptyWorkItemWhenNoItemsWereAdded() { //arrange WorkItemsList itemsList = new WorkItemsList(); //act WorkItem result = itemsList.LastItem; //assert Assert.AreEqual(0, result.Id); Assert.AreEqual(string.Empty, result.Title); Assert.AreEqual(1, result.Comments.Count); }
public void ShouldThrowExceptionWhenIndexIsOutOfRange() { //arrange WorkItem item = new WorkItem(1, "title", null); WorkItemsList itemsList = new WorkItemsList(); int INDEX = 1; itemsList.Add(item); //act WorkItem result = itemsList[INDEX]; }
public void ShouldSetCountCorrectlyAfterAddingThreeItems() { //arrange const int EXP_COUNT = 3; List<WorkItem> elements = new List<WorkItem>(); elements.Add(new WorkItem(1, "title1", null)); elements.Add(new WorkItem(2, "title1", null)); elements.Add(new WorkItem(3, "title1", null)); //act WorkItemsList itemsList = new WorkItemsList(elements); //assert Assert.AreEqual(EXP_COUNT, itemsList.Count); }
public void ShouldReturnWorkItemEmptyWhenIndexBelowZero() { //arrange WorkItem item = new WorkItem(1, "title", null); WorkItemsList itemsList = new WorkItemsList(); itemsList.Add(item); int INDEX = -1; //act WorkItem result = itemsList[INDEX]; //assert Assert.AreEqual(0, result.Id); Assert.AreEqual(string.Empty, result.Title); Assert.AreEqual(string.Empty, result.Comments[0].Title); }
public void ShouldReturnSecondItemWhenUsingLastItemProperty() { //arrange WorkItem firstItem = new WorkItem(1, "title", null); WorkItem secondItem = new WorkItem(2, "newWI", null); WorkItemsList itemsList = new WorkItemsList(); itemsList.Add(firstItem); itemsList.Add(secondItem); //act WorkItem result = itemsList.LastItem; //assert Assert.AreEqual(2, result.Id); Assert.AreEqual("newWI", result.Title); Assert.AreEqual(null, result.Comments); }
public void ShouldReturnFirstItemWhenUsingIndexerWithIndexZero() { //arrange WorkItem item = new WorkItem(1, "title", null); WorkItemsList itemsList = new WorkItemsList(); int INDEX = 0; itemsList.Add(item); //act WorkItem result = itemsList[INDEX]; //assert Assert.AreEqual(1, result.Id); Assert.AreEqual("title" , result.Title); Assert.AreEqual(null, result.Comments); }
public void UpdateData(WorkItemsList workItems) { _summaryData = workItems; }
/// <summary> /// Updates summary view with list of work items. /// </summary> public void UpdateSummaryView(WorkItemsList workItems) { _reportSummary.UpdateData(workItems); }