public void AddAndGetWorklogs() { var summaryValue = "Test issue with work logs" + _random.Next(int.MaxValue); var issue = new Issue(_jira, "TST") { Type = "1", Summary = summaryValue, Assignee = "admin" }; issue.SaveChanges(); issue.AddWorklog("1d"); issue.AddWorklog("1h", WorklogStrategy.RetainRemainingEstimate); issue.AddWorklog("1m", WorklogStrategy.NewRemainingEstimate, "2d"); issue.AddWorklog(new Worklog("2d", new DateTime(2012, 1, 1), "comment")); var logs = issue.GetWorklogs(); Assert.Equal(4, logs.Count); Assert.Equal("comment", logs.ElementAt(3).Comment); Assert.Equal(new DateTime(2012, 1, 1), logs.ElementAt(3).StartDate); }
public void DeleteWorklog() { var summary = "Test issue with worklogs" + _random.Next(int.MaxValue); var issue = new Issue(_jira, "TST") { Type = "1", Summary = summary, Assignee = "admin" }; issue.SaveChanges(); var worklog = issue.AddWorklog("1h"); Assert.Equal(1, issue.GetWorklogs().Count); issue.DeleteWorklog(worklog); Assert.Equal(0, issue.GetWorklogs().Count); }
public void LogTime(Issue jiraIssue, DateTime exportTimeStamp, TimeSpan exportTime, WorklogStrategy strategy, string comment = "", TimeSpan?remainingTime = null) { var wasClosed = TryReopenJira(jiraIssue); if (string.IsNullOrWhiteSpace(comment)) { comment = "No Comment Entered"; } comment = "Gallifrey: " + comment; var worklog = new Worklog(string.Format("{0}h {1}m", exportTime.Hours, exportTime.Minutes), DateTime.SpecifyKind(exportTimeStamp, DateTimeKind.Local), comment); string remaining = null; if (remainingTime.HasValue) { remaining = string.Format("{0}h {1}m", exportTime.Hours, exportTime.Minutes); } try { jiraIssue.AddWorklog(worklog, strategy, remaining); } catch (Exception ex) { throw new WorkLogException("Error logging work", ex); } if (wasClosed) { try { ReCloseJira(jiraIssue); } catch (Exception ex) { throw new StateChangedException("Time Logged, but state is now open", ex); } } }
public void LogTime(Issue jiraIssue, DateTime exportTimeStamp, TimeSpan exportTime, WorklogStrategy strategy, string comment = "", TimeSpan? remainingTime = null) { var wasClosed = TryReopenJira(jiraIssue); if (string.IsNullOrWhiteSpace(comment)) comment = "No Comment Entered"; comment = "Gallifrey: " + comment; var worklog = new Worklog(string.Format("{0}h {1}m", exportTime.Hours, exportTime.Minutes), DateTime.SpecifyKind(exportTimeStamp, DateTimeKind.Local), comment); string remaining = null; if (remainingTime.HasValue) { remaining = string.Format("{0}h {1}m", exportTime.Hours, exportTime.Minutes); } try { jiraIssue.AddWorklog(worklog, strategy, remaining); } catch (Exception ex) { throw new WorkLogException("Error logging work", ex); } if (wasClosed) { try { ReCloseJira(jiraIssue); } catch (Exception ex) { throw new StateChangedException("Time Logged, but state is now open", ex); } } }