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);
        }
Пример #2
0
        public async Task create_sprint_command_should_add_sprint_with_given_data_to_database()
        {
            var sprintId    = "sprintKey" + Guid.NewGuid();
            var title       = "Title";
            var description = "description";
            var projectId   = "projectKey" + Guid.NewGuid();
            var startDate   = DateTime.MinValue;
            var endDate     = DateTime.MaxValue;

            var expectedSprintKey = $"{projectId}-Sprint-1";

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


            var command = new CreateSprint(sprintId, title, description, projectId, startDate, endDate);

            // Check if exception is thrown

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


            var sprint = await _sprintMongoDbFixture.GetAsync(expectedSprintKey);

            sprint.Should().NotBeNull();
            sprint.Id.Should().Be(expectedSprintKey);
            sprint.Title.Should().Be(title);
            sprint.Description.Should().Be(description);
            sprint.ProjectId.Should().Be(projectId);
            sprint.StartDate.Should().Be(startDate);
            sprint.EndDate.Should().Be(endDate);
        }
Пример #3
0
        public async Task resetpassword_command_should_fail_if_token_is_invalid()
        {
            var id                   = new AggregateId();
            var email                = "*****@*****.**";
            var fullname             = "fullname";
            var updatedFullname      = "updatedfullname";
            var password             = "******";
            var newPassword          = "******";
            var pic                  = "test.nl/image";
            var role                 = Role.User;
            var securityStamp        = Guid.NewGuid().ToString();
            var invalidSecurityStamp = Guid.NewGuid().ToString();

            // Add user
            var user = new User(id, email, fullname, pic, password, role, securityStamp, 0, DateTime.MinValue, DateTime.UtcNow,
                                new string[] { });
            await _mongoDbFixture.InsertAsync(user.AsDocument());

            // generate reset token
            var token = await _dataProtectorTokenProvider.GenerateAsync(Purpose, id, invalidSecurityStamp);

            var command = new ResetPassword(id, newPassword, token);

            _commandHandler
            .Awaiting(c => c.HandleAsync(command))
            .Should().Throw <InvalidTokenException>();
        }
        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 forgotpassword_command_fails_when_user_does_not_exist()
        {
            var email = "*****@*****.**";

            var command = new ForgotPassword(email);

            // Check if exception is thrown
            _commandHandler
            .Awaiting(c => c.HandleAsync(command))
            .Should().Throw <InvalidEmailException>();
        }
Пример #6
0
        public async Task updateuser_command_fails_when_user_does_not_exist()
        {
            var id              = new AggregateId();
            var email           = "*****@*****.**";
            var fullname        = "fullname";
            var updatedFullname = "updatedfullname";
            var password        = "******";
            var pic             = "test.nl/image";
            var role            = Role.User;
            var securityStamp   = new Guid().ToString();

            // Add user

            var command = new UpdateUser(id, updatedFullname, pic, null);

            // Check if exception is thrown
            _commandHandler
            .Awaiting(c => c.HandleAsync(command))
            .Should().Throw <UserNotFoundException>();
        }
        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();
        }
Пример #8
0
        public async Task signup_command_fails_when_user_with_email_alreadt_exists_in_database()
        {
            var id            = new AggregateId();
            var email         = "*****@*****.**";
            var fullname      = "fullname";
            var password      = "******";
            var role          = Role.User;
            var securityStamp = new Guid().ToString();

            // Add user
            var user = new User(id, email, fullname, "test.nl/image", password, role, securityStamp, 0, DateTime.MinValue, DateTime.UtcNow,
                                new string[] { });
            await _mongoDbFixture.InsertAsync(user.AsDocument());

            // Add user with same email
            var command = new SignUp(id, email, fullname, "test.nl/image", password, role, new string[] { });

            // Check if exception is thrown
            _commandHandler
            .Awaiting(c => c.HandleAsync(command))
            .Should().Throw <EmailInUseException>();
        }
Пример #9
0
        public async Task create_issue_command_should_add_issue_with_given_data_to_database()
        {
            var projectId   = "projectkey";
            var epicId      = string.Empty;
            var issueId     = string.Empty;
            var title       = "Title";
            var description = "description";
            var type        = IssueType.Story;
            var status      = IssueStatus.TODO;
            var storypoints = 0;

            var expectedIssueId = $"{projectId}-1";

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


            var command = new CreateIssue(issueId, type, status, title, description, storypoints, projectId, epicId, null, null, DateTime.Now);

            // Check if exception is thrown

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


            var issue = await _issuesMongoDbFixture.GetAsync(expectedIssueId);

            issue.Should().NotBeNull();
            issue.Id.Should().Be(expectedIssueId);
            issue.Type.Should().Be(type);
            issue.Status.Should().Be(status);
            issue.Title.Should().Be(title);
            issue.Description.Should().Be(description);
            issue.StoryPoints.Should().Be(storypoints);
            issue.ProjectId.Should().Be(projectId);
        }