public async void remove_issue_from_sprint_command_fails_when_issue_does_not_exist()
        {
            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 command = new RemoveIssueFromSprint(sprintId, issueId);


            // Check if exception is thrown

            _commandHandler
            .Awaiting(c => c.HandleAsync(command))
            .Should().Throw <IssueNotFoundException>();
        }
        public async Task end_sprint_command_should_set_endedAt()
        {
            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.Now;
            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 command = new EndSprint(sprintId);

            // Check if exception is thrown

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


            var startedSprint = await _sprintMongoDbFixture.GetAsync(sprintId);

            startedSprint.Should().NotBeNull();
            startedSprint.StartedAt.Should().BeCloseTo(DateTime.Now, TimeSpan.FromSeconds(10));
            startedSprint.EndedAt.Should().BeCloseTo(DateTime.Now, TimeSpan.FromSeconds(10));
        }
        public async Task end_sprint_command_fails_when_sprint_has_not_been_started()
        {
            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 command = new EndSprint(sprintId);

            // Check if exception is thrown

            _commandHandler
            .Awaiting(c => c.HandleAsync(command))
            .Should().Throw <SprintNotStartedException>();
        }
        public async Task get_sprint_query_succeeds_when_sprint_exists()
        {
            var sprintId    = "sprintKey" + Guid.NewGuid();
            var title       = "Title";
            var description = "description";
            var projectId   = "projectKey" + Guid.NewGuid();
            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 query = new GetSprint(sprintId);

            // 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(sprintId);
            result.Title.Should().Be(title);
            result.Description.Should().Be(description);
        }
        public async Task UpdateAsync(Sprint sprint)
        {
            var sprintToUpdate = await _repository.GetAsync(sprint.Id);

            sprint.StartedAt = sprint.StartedAt != DateTime.MinValue ? sprint.StartedAt : sprintToUpdate.StartedAt;
            sprint.EndedAt   = sprint.EndedAt != DateTime.MinValue ? sprint.EndedAt : sprintToUpdate.EndedAt;

            await _repository.UpdateAsync(sprint.AsDocument());
        }
Exemple #6
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 get_sprints_query_succeeds_when_a_sprint_exists()
        {
            var sprintId    = "sprintKey" + Guid.NewGuid();
            var sprint2Id   = "sprint2Key" + Guid.NewGuid();
            var title       = "Title";
            var description = "description";
            var projectId   = "projectKey" + Guid.NewGuid();
            var createdAt   = DateTime.Now;
            var startedAt   = DateTime.MinValue;
            var startDate   = DateTime.MinValue;
            var endDate     = DateTime.MaxValue;
            var endedAt     = DateTime.MaxValue;

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

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

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

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


            var query = new GetSprints(projectId);

            // Check if exception is thrown

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

            requestResult.Should().NotThrow();

            var result = await requestResult();

            var sprintDtos = result as SprintDto[] ?? result.ToArray();

            sprintDtos.Should().Contain(i => i.Id == sprintId);
            sprintDtos.Should().Contain(i => i.Id == sprint2Id);
        }
        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();
        }
 public Task AddAsync(Sprint sprint) => _repository.AddAsync(sprint.AsDocument());