public async Task CanLinkTwoNewIssuesTogetherThenFetchThem()
        {
            // Given two issues
            var sourceIssue = await _issuesClient.CreateAsync(TestProjectTextId,
                                                              new CreateIssueRequest("IssueLink_Title_1"));

            var targetIssue = await _issuesClient.CreateAsync(TestProjectTextId,
                                                              new CreateIssueRequest("IssueLink_Title_2"));

            // When I link the first as BlockedBy the second
            var retFromPost = await _sut.CreateAsync(TestProjectTextId,
                                                     sourceIssue.Iid,
                                                     options =>
            {
                options.TargetProjectId = TestProjectTextId;
                options.TargetIid       = targetIssue.Iid;
            });

            // Then the relation is created
            retFromPost.Should().Match <IssuesLinkRelation>(testee => testee.LinkType == LinkType.RelatesTo &&
                                                            testee.SourceIssue.Iid == sourceIssue.Iid &&
                                                            testee.TargetIssue.Iid == targetIssue.Iid);

            // When I fetch it from the links API
            var retFromGet = await _sut.GetAsync(TestProjectTextId, sourceIssue.Iid);

            // Then the result is the same
            retFromGet.Should().NotBeNullOrEmpty();
            retFromGet.Should().HaveCount(1);

            retFromGet.Single().Should().Match <IssueLink>(testee => testee.LinkType == LinkType.RelatesTo &&
                                                           testee.Iid == targetIssue.Iid);
        }
        public async Task RetrieveToDoListAndMarkAsDone()
        {
            var mergeRequest = await mergeRequestsClient.CreateAsync(GitLabApiHelper.TestProjectTextId, new CreateMergeRequest("sourcebranch1", "master", "Title")
            {
                AssigneeId = GitLabApiHelper.TestUserId
            });

            var issue = await issuesClient.CreateAsync(GitLabApiHelper.TestProjectTextId, new CreateIssueRequest("IssueTitle")
            {
                Assignees = new List <int> {
                    GitLabApiHelper.TestUserId
                }
            });

            // todoList is populated
            var todoList = await _sut.GetAsync();

            todoList.Should().Contain(t =>
                                      t.ActionType == ToDoActionType.Assigned &&
                                      t.Body == "IssueTitle" &&
                                      t.TargetType == ToDoTargetType.Issue
                                      );
            todoList.Should().Contain(t =>
                                      t.ActionType == ToDoActionType.Assigned &&
                                      t.Body == "Title" &&
                                      t.TargetType == ToDoTargetType.MergeRequest
                                      );

            // mark the mergeRequest as done
            var mergeToDo = todoList.Single(t => t.TargetType == ToDoTargetType.MergeRequest);

            mergeToDo.Id.HasValue.Should().BeTrue();
            await _sut.MarkAsDoneAsync(mergeToDo.Id ?? 1);

            todoList = await _sut.GetAsync();

            todoList.Should().NotContain(t => t.TargetType == ToDoTargetType.MergeRequest);

            // mark all toDos as done
            await _sut.MarkAllAsDoneAsync();

            todoList = await _sut.GetAsync();

            todoList.Should().BeEmpty();
        }
Beispiel #3
0
        public async Task CreatedIssueCanBeUpdated()
        {
            //arrange
            var createdIssue = await _sut.CreateAsync(TestProjectTextId, new CreateIssueRequest("Title1")
            {
                Assignees = new List<int> { 1 },
                Confidential = true,
                Description = "Description1",
                Labels = new[] { "Label1" },
                MilestoneId = 2,
                DiscussionToResolveId = 3,
                MergeRequestIdToResolveDiscussions = 4
            });

            //act
            var updatedIssue = await _sut.UpdateAsync(TestProjectTextId, createdIssue.Iid, new UpdateIssueRequest()
            {
                Assignees = new List<int> { 11 },
                Confidential = false,
                Description = "Description11",
                Labels = new[] { "Label11" },
                Title = "Title11",
                MilestoneId = 22
            });

            //assert
            updatedIssue.Should().Match<Issue>(i =>
                i.ProjectId == TestProjectTextId &&
                i.Confidential == false &&
                i.Description == "Description11" &&
                i.Labels.SequenceEqual(new[] { "Label11" }) &&
                i.Title == "Title11");
        }