public async Task update_issue_command_should_update_issue_with_given_data_to()
        {
            var projectId          = "projectKey";
            var epicId             = string.Empty;
            var issueId            = "issueKey";
            var sprintId           = string.Empty;
            var title              = "Title";
            var updatedTitle       = "UpdatedTitle";
            var description        = "description";
            var updatedDescription = "updatedDescription";
            var type        = IssueType.Story;
            var status      = IssueStatus.TODO;
            var storypoints = 0;

            var issue = new Issue(issueId, type, status, title, description, storypoints, projectId, epicId, sprintId, null, null, DateTime.Now);
            await _issuesMongoDbFixture.InsertAsync(issue.AsDocument());

            var command = new UpdateIssue(issueId, type, status, updatedTitle, updatedDescription, storypoints, epicId, null, null);

            // Check if exception is thrown

            _commandHandler
            .Awaiting(c => c.HandleAsync(command))
            .Should().NotThrow();


            var updatedIssue = await _issuesMongoDbFixture.GetAsync(command.IssueId);

            updatedIssue.Should().NotBeNull();
            updatedIssue.Id.Should().Be(issueId);
            updatedIssue.Title.Should().Be(updatedTitle);
            updatedIssue.Description.Should().Be(updatedDescription);
        }
Exemple #2
0
        public async Task getissues_query_returns_empty_when_project_does_not_exist()
        {
            var projectId   = "projectKey";
            var epicId      = "epicKey";
            var issueId     = "issueKey";
            var sprintId    = string.Empty;
            var title       = "Title";
            var description = "description";
            var type        = IssueType.Story;
            var status      = IssueStatus.TODO;
            var storypoints = 0;

            var issue = new Issue(issueId, type, status, title, description, storypoints, projectId, epicId, sprintId, null, null, DateTime.Now);
            await _issuesMongoDbFixture.InsertAsync(issue.AsDocument());

            var query = new GetIssues(projectId);

            // Check if exception is thrown

            var requestResult = _queryHandler
                                .Awaiting(c => c.HandleAsync(query));

            requestResult.Should().NotThrow();

            var result = await requestResult();

            result.Should().BeEmpty();
        }
        public async Task issue_created_event_fails_when_issue_with_id_already_exists()
        {
            var issueId   = "issueKey" + Guid.NewGuid();
            var projectId = "projectKey" + Guid.NewGuid();

            var project = new Project(projectId);
            await _projectMongoDbFixture.InsertAsync(project.AsDocument());

            var issue = new Issue(issueId, projectId, null);
            await _issueMongoDbFixture.InsertAsync(issue.AsDocument());

            var externalEvent = new IssueCreated(issueId, projectId);

            // Check if exception is thrown

            _eventHandler
            .Awaiting(c => c.HandleAsync(externalEvent))
            .Should().Throw <IssueAlreadyCreatedException>();
        }
Exemple #4
0
        public async Task get_issues_without_sprint_for_project_query_succeeds_when_a_issue_without_sprint_exists()
        {
            var projectId = "projectKey" + Guid.NewGuid();

            var project = new Project(projectId);
            await _projectMongoDbFixture.InsertAsync(project.AsDocument());

            var sprintId    = "sprintKey" + Guid.NewGuid();
            var title       = "Title";
            var description = "description";
            var createdAt   = DateTime.Now;
            var startedAt   = DateTime.MinValue;
            var startDate   = DateTime.MinValue;
            var endDate     = DateTime.MaxValue;
            var endedAt     = DateTime.MaxValue;

            var sprint = new Sprint(sprintId, title, description, projectId, null, createdAt, startedAt, startDate, endDate, endedAt);

            await _sprintMongoDbFixture.InsertAsync(sprint.AsDocument());

            var issueId = "issueKey" + Guid.NewGuid();
            var issueWithoutSprintId = "issueWithoutSprintKey";

            var issue = new Issue(issueId, projectId, sprintId);
            var issueWithoutSprint = new Issue(issueWithoutSprintId, projectId, null);
            await _issueMongoDbFixture.InsertAsync(issue.AsDocument());

            await _issueMongoDbFixture.InsertAsync(issueWithoutSprint.AsDocument());

            var query = new GetIssuesWithoutSprintForProject(projectId);

            // Check if exception is thrown

            var requestResult = _queryHandler
                                .Awaiting(c => c.HandleAsync(query));

            requestResult.Should().NotThrow();

            var result = await requestResult();

            result.Should().NotContain(issueId);
            result.Should().Contain(issueWithoutSprintId);
        }
        public async Task remove_issue_from_sprint_command_should_remove_issue_from_sprint()
        {
            var projectId = "projectKey" + Guid.NewGuid();

            var project = new Project(projectId);
            await _projectMongoDbFixture.InsertAsync(project.AsDocument());

            var sprintId    = "sprintKey" + Guid.NewGuid();
            var title       = "Title";
            var description = "description";
            var createdAt   = DateTime.Now;
            var startedAt   = DateTime.MinValue;
            var startDate   = DateTime.MinValue;
            var endDate     = DateTime.MaxValue;
            var endedAt     = DateTime.MaxValue;

            var sprint = new Sprint(sprintId, title, description, projectId, null, createdAt, startedAt, startDate, endDate, endedAt);
            await _sprintMongoDbFixture.InsertAsync(sprint.AsDocument());

            var issueId = "issueKey" + Guid.NewGuid();

            var issue = new Issue(issueId, projectId, sprintId);
            await _issueMongoDbFixture.InsertAsync(issue.AsDocument());


            var command = new RemoveIssueFromSprint(sprintId, issueId);

            // Check if exception is thrown

            _commandHandler
            .Awaiting(c => c.HandleAsync(command))
            .Should().NotThrow();


            var removedIssue = await _issueMongoDbFixture.GetAsync(issueId);

            removedIssue.Should().NotBeNull();
            removedIssue.SprintId.Should().BeNull();
        }
Exemple #6
0
        public async Task getissues_query_succeeds_when_a_issue_exists()
        {
            var projectId   = "projectKey";
            var epicId      = "epicKey";
            var issueId     = "issueKey";
            var issue2Id    = "issueKey2";
            var sprintId    = string.Empty;
            var title       = "Title";
            var description = "description";
            var type        = IssueType.Story;
            var status      = IssueStatus.TODO;
            var storypoints = 0;

            var project = new Project(projectId);
            await _projectsMongoDbFixture.InsertAsync(project.AsDocument());

            var issue  = new Issue(issueId, type, status, title, description, storypoints, projectId, epicId, sprintId, null, null, DateTime.Now);
            var issue2 = new Issue(issue2Id, type, status, title, description, storypoints, projectId, epicId, sprintId, null, null, DateTime.Now);
            await _issuesMongoDbFixture.InsertAsync(issue.AsDocument());

            await _issuesMongoDbFixture.InsertAsync(issue2.AsDocument());

            var query = new GetIssues(projectId: projectId);

            // Check if exception is thrown

            var requestResult = _queryHandler
                                .Awaiting(c => c.HandleAsync(query));

            requestResult.Should().NotThrow();

            var result = await requestResult();

            var issueDtos = result as IssueDto[] ?? result.ToArray();

            issueDtos.Should().Contain(i => i.Id == issueId);
            issueDtos.Should().Contain(i => i.Id == issue2Id);
        }
        public async Task getissue_query_succeeds_when_issue_exists()
        {
            var projectId   = "projectKey";
            var epicId      = "epicKey";
            var issueId     = "issueKey";
            var sprintId    = string.Empty;
            var title       = "Title";
            var description = "description";
            var type        = IssueType.Story;
            var status      = IssueStatus.TODO;
            var storypoints = 0;

            var project = new Project(projectId);
            await _projectsMongoDbFixture.InsertAsync(project.AsDocument());

            var issue = new Issue(issueId, type, status, title, description, storypoints, projectId, epicId, sprintId, null, null, DateTime.Now);
            await _issuesMongoDbFixture.InsertAsync(issue.AsDocument());

            var query = new GetIssue(issueId);

            // Check if exception is thrown

            var requestResult = _queryHandler
                                .Awaiting(c => c.HandleAsync(query));

            requestResult.Should().NotThrow();

            var result = await requestResult();

            result.Should().NotBeNull();
            result.Id.Should().Be(issueId);
            result.Type.Should().Be(type);
            result.Status.Should().Be(status);
            result.Title.Should().Be(title);
            result.Description.Should().Be(description);
            result.StoryPoints.Should().Be(storypoints);
            result.ProjectId.Should().Be(projectId);
        }
        public async void remove_issue_from_sprint_command_fails_when_sprint_does_not_exist()
        {
            var projectId = "projectKey" + Guid.NewGuid();

            var project = new Project(projectId);
            await _projectMongoDbFixture.InsertAsync(project.AsDocument());

            var sprintId = "sprintKey" + Guid.NewGuid();

            var issueId = "issueKey" + Guid.NewGuid();

            var issue = new Issue(issueId, projectId, null);
            await _issueMongoDbFixture.InsertAsync(issue.AsDocument());


            var command = new RemoveIssueFromSprint(sprintId, issueId);


            // Check if exception is thrown

            _commandHandler
            .Awaiting(c => c.HandleAsync(command))
            .Should().Throw <SprintNotFoundException>();
        }
        public async Task update_issue_command_fails_when_epic_does_not_exist()
        {
            var projectId   = "projectKey";
            var epicId      = "epicKey";
            var issueId     = "issueKey";
            var sprintId    = string.Empty;
            var title       = "Title";
            var description = "description";
            var type        = IssueType.Story;
            var status      = IssueStatus.TODO;
            var storypoints = 0;


            var issue = new Issue(issueId, type, status, title, description, storypoints, projectId, string.Empty, sprintId, null, null, DateTime.Now);
            await _issuesMongoDbFixture.InsertAsync(issue.AsDocument());

            var command = new UpdateIssue(issueId, type, status, title, description, storypoints, epicId, null, null);

            // Check if exception is thrown

            _commandHandler
            .Awaiting(c => c.HandleAsync(command))
            .Should().Throw <EpicNotFoundException>();
        }
 public Task UpdateAsync(Issue issue) => _repository.UpdateAsync(issue.AsDocument());
 public Task AddAsync(Issue issue) => _repository.AddAsync(issue.AsDocument());