Пример #1
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);
        }
Пример #2
0
        public async Task <IActionResult> Create([FromRoute] Guid projectId, [FromBody] CreateSprint command)
        {
            command.ProjectId = projectId;
            await commandQueryBus.SendAsync(command);

            return(Created("api/project-management/sprint/", command.CreatedId));
        }
Пример #3
0
        public async Task <Model.Sprint> GenerateSprint(CreateSprint command)
        {
            await authorizationService.CheckUserMembership(callContext.UserId, command.ProjectId);

            if (!await projectSearcher.DoesProjectExist(command.ProjectId))
            {
                throw new EntityDoesNotExist(command.ProjectId, nameof(Project.Model.Project));
            }

            var sprint = new Model.Sprint(Guid.NewGuid(), command.ProjectId, command.Name, command.Start, command.End);

            sprint.Created();
            command.CreatedId = sprint.Id;
            return(sprint);
        }
Пример #4
0
        public void create_sprint_command_fails_when_project_does_not_exist()
        {
            var sprintId    = "sprintId" + Guid.NewGuid();
            var title       = "Title";
            var description = "description";
            var projectId   = "projectId" + Guid.NewGuid();
            var startDate   = DateTime.MinValue;
            var endDate     = DateTime.MaxValue;

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


            // Check if exception is thrown

            _commandHandler
            .Awaiting(c => c.HandleAsync(command))
            .Should().Throw <ProjectNotFoundException>();
        }
Пример #5
0
        public void SeedData(ICommandQueryBus commandQueryBus, IEventManager eventManager)
        {
            var queue                  = new Queue <IDomainEvent>();
            var adminCreated           = new UserCreated(AdminId, "Admin", "Admin", "*****@*****.**", Role.Admin);
            var userAssignedCreated    = new UserCreated(UserAssignedToProjectId, "Assigned", "Assigned", "*****@*****.**", Role.User);
            var userNotAssignedCreated = new UserCreated(UserNotAssignedToProjectId, "NotAssigned", "NotAssigned", "*****@*****.**", Role.User);

            queue.Enqueue(adminCreated);
            queue.Enqueue(userAssignedCreated);
            queue.Enqueue(userNotAssignedCreated);

            var createProject = new CreateProject(ProjectName);

            Task.Run(() => eventManager.PublishEventsAsync(queue)).Wait();

            Task.Run(() => commandQueryBus.SendAsync(createProject)).Wait();
            ProjectId = createProject.CreatedId;

            //Task.Run(() => commandQueryBus.SendAsync(new AssignUserToProject(AdminId, UserAssignedToProjectId, 1) { ProjectId = ProjectId})).Wait();

            AddLabel createLabel;

            for (int i = 0; i < 5; i++)
            {
                createLabel = new AddLabel(RandomString("NAME_"), RandomString("DESCR_"))
                {
                    ProjectId = ProjectId
                };
                Task.Run(() => commandQueryBus.SendAsync(createLabel)).Wait();
                LabelsIds.Add(createLabel.CreatedId);
            }


            var createTask = IssueExtensions.GenerateBasicCreateTaskCommand(this);

            Task.Run(() => commandQueryBus.SendAsync(createTask)).Wait();
            TaskId = createTask.CreatedId;

            var createNfr = IssueExtensions.GenerateBasicCreateNfrCommand(this);

            Task.Run(() => commandQueryBus.SendAsync(createNfr)).Wait();
            NfrId = createNfr.CreatedId;

            var createTasksBug = IssueExtensions.GenerateBasicAddBugToCommand(this, IssueType.Task);

            Task.Run(() => commandQueryBus.SendAsync(createTasksBug)).Wait();
            TasksBugId = createTasksBug.CreatedId;

            var createNfrsBug = IssueExtensions.GenerateBasicAddBugToCommand(this, IssueType.Nfr);

            Task.Run(() => commandQueryBus.SendAsync(createNfrsBug)).Wait();
            NfrsBugId = createNfrsBug.CreatedId;

            var createSprint = new CreateSprint(RandomString("Sprint_"), DateTime.UtcNow.Date, DateTime.UtcNow.Date.AddDays(14))
            {
                ProjectId = ProjectId
            };

            Task.Run(() => commandQueryBus.SendAsync(createSprint)).Wait();
            SprintId = createSprint.CreatedId;
        }