public async Task Analyzed_as_valid_issue() { var stateFiltering = new StateFilteringParameter(new string[0], new string[0]); var issue = new CachedIssue() { Project = DefaultProjectKey, Key = DefaultProjectKey + "-1", Type = "Story", StatusChanges = new Collection <CachedIssueStatusChange>() }; _jiraCacheAdapter.Issues.Add(issue); var issues = await _tasksSource.GetAllIssues(DefaultProjectKey, stateFiltering); var analyzedIssue = Assert.Single(issues); var expectedIssue = new AnalyzedIssue() { Project = DefaultProjectKey, Key = DefaultProjectKey + "-1", Type = "Story", StatusChanges = issue.StatusChanges, SimplifiedStatusChanges = new Collection <CachedIssueStatusChange>() }; _compareLogic.AssertEqual <object>(expectedIssue, analyzedIssue); }
public async Task Non_started_issue_is_analyzed() { var stateFiltering = new StateFilteringParameter(new [] { "B" }, new string[0]); var issue = new CachedIssue() { Project = DefaultProjectKey, Key = DefaultProjectKey + "-1", StatusChanges = new Collection <CachedIssueStatusChange>() { new CachedIssueStatusChange(new DateTime(2012, 1, 1), "A"), } }; _jiraCacheAdapter.Issues.Add(issue); var issues = await _tasksSource.GetAllIssues(DefaultProjectKey, stateFiltering); var analyzedIssue = Assert.Single(issues); var expectedIssue = new AnalyzedIssue() { Project = DefaultProjectKey, Key = DefaultProjectKey + "-1", StatusChanges = issue.StatusChanges, SimplifiedStatusChanges = new Collection <CachedIssueStatusChange>(), Started = null, Ended = null, Duration = null }; _compareLogic.AssertEqual <object>(expectedIssue, analyzedIssue); }
public async Task Retrieves_issue(CachedIssue issue) { var stateFiltering = new StateFilteringParameter(new string[0], new string[0]); issue.Project = DefaultProjectKey; issue.Key = DefaultProjectKey + "-1"; _jiraCacheAdapter.Issues.Add(issue); var issues = await _tasksSource.GetAllIssues(DefaultProjectKey, stateFiltering); _compareLogic.AssertEqual <object>(issues, _jiraCacheAdapter.Issues); }
public async Task AddOrReplaceCachedIssue(CachedIssue issue) { var existingIssue = await _dbContext.Issues.FirstOrDefaultAsync(x => x.Key == issue.Key); if (existingIssue != null) { _dbContext.Issues.Remove(existingIssue); } await _dbContext.SaveChangesAsync(); CachedIssueDb issueDb = _mapper.Map <CachedIssueDb>(issue); _dbContext.Issues.Add(issueDb); await _dbContext.SaveChangesAsync(); }
public async Task Finished_story_must_have_start() { var stateFiltering = new StateFilteringParameter(new [] { "A", "C" }, new string[0]); var issue = new CachedIssue() { Type = "Story", StatusChanges = new Collection <CachedIssueStatusChange>() { new CachedIssueStatusChange(new DateTime(2012, 2, 2), "B"), } }; _jiraCacheAdapter.Issues.Add(issue); var issues = await _tasksSource.GetLatestFinishedStories(DefaultProjectKey, new IssuesFromParameters(null), stateFiltering); Assert.Empty(issues); }
public async Task Finished_issue_is_analyzed() { var stateFiltering = new StateFilteringParameter(new [] { "A", "C" }, new string[0]); var issue = new CachedIssue() { Project = DefaultProjectKey, Key = DefaultProjectKey + "-1", Title = "Title", Type = "Story", StoryPoints = 12, StatusChanges = new Collection <CachedIssueStatusChange>() { new CachedIssueStatusChange(new DateTime(2012, 2, 1), "A"), new CachedIssueStatusChange(new DateTime(2012, 2, 2), "B"), new CachedIssueStatusChange(new DateTime(2012, 2, 3), "C"), } }; _jiraCacheAdapter.Issues.Add(issue); var issues = await _tasksSource.GetLatestFinishedStories(DefaultProjectKey, new IssuesFromParameters(new DateTime(2012, 1, 1)), stateFiltering); var analyzedIssue = Assert.Single(issues); var expectedIssue = new FinishedIssue() { Project = DefaultProjectKey, Key = DefaultProjectKey + "-1", Title = issue.Title, Type = issue.Type, StoryPoints = issue.StoryPoints, StatusChanges = new Collection <CachedIssueStatusChange>() { new CachedIssueStatusChange(new DateTime(2012, 2, 1), "A"), new CachedIssueStatusChange(new DateTime(2012, 2, 3), "C"), }, Started = new DateTime(2012, 2, 1), Ended = new DateTime(2012, 2, 3), Duration = TimeSpan.FromDays(2) }; _compareLogic.AssertEqual(expectedIssue, analyzedIssue); }
public async Task Analyzed_issue_contains_simplified_states() { var stateFiltering = new StateFilteringParameter(new [] { "A", "C" }, new [] { "D" }); var issue = new CachedIssue() { Project = DefaultProjectKey, Key = DefaultProjectKey + "-1", StatusChanges = new Collection <CachedIssueStatusChange>() { new CachedIssueStatusChange(new DateTime(2012, 1, 1), "A"), new CachedIssueStatusChange(new DateTime(2012, 1, 2), "D"), new CachedIssueStatusChange(new DateTime(2012, 2, 1), "A"), new CachedIssueStatusChange(new DateTime(2012, 2, 2), "B"), new CachedIssueStatusChange(new DateTime(2012, 2, 3), "C"), } }; _jiraCacheAdapter.Issues.Add(issue); var issues = await _tasksSource.GetAllIssues(DefaultProjectKey, stateFiltering); var analyzedIssue = Assert.Single(issues); var expectedIssue = new AnalyzedIssue { Project = DefaultProjectKey, Key = DefaultProjectKey + "-1", StatusChanges = issue.StatusChanges, SimplifiedStatusChanges = new Collection <CachedIssueStatusChange>() { new CachedIssueStatusChange(new DateTime(2012, 2, 1), "A"), new CachedIssueStatusChange(new DateTime(2012, 2, 3), "C"), }, Started = new DateTime(2012, 2, 1), Ended = new DateTime(2012, 2, 3), Duration = TimeSpan.FromDays(2) }; _compareLogic.AssertEqual <object>(expectedIssue, analyzedIssue); }
public async Task Filters_out_old_issues() { var stateFiltering = new StateFilteringParameter(new [] { "A", "C" }, new string[0]); var issuesFrom = new DateTime(2012, 2, 3).AddSeconds(1); var issue = new CachedIssue() { Key = "AC-1", Title = "Title", Type = "Story", StoryPoints = 12, StatusChanges = new Collection <CachedIssueStatusChange>() { new CachedIssueStatusChange(new DateTime(2012, 2, 1), "A"), new CachedIssueStatusChange(new DateTime(2012, 2, 2), "B"), new CachedIssueStatusChange(new DateTime(2012, 2, 3), "C"), } }; _jiraCacheAdapter.Issues.Add(issue); var issues = await _tasksSource.GetLatestFinishedStories(DefaultProjectKey, new IssuesFromParameters(issuesFrom), stateFiltering); Assert.Empty(issues); }