Exemplo n.º 1
0
            public void Should_Set_Correct_Id()
            {
                // Given
                var id       = 123;
                var status   = CommentThreadStatus.Active;
                var filePath = "/foo.cs";
                var thread   =
                    new GitPullRequestCommentThread
                {
                    Id            = id,
                    Status        = status,
                    ThreadContext = new CommentThreadContext()
                    {
                        FilePath = filePath
                    },
                    Comments   = new List <Comment>(),
                    Properties = new PropertiesCollection()
                };

                // When
                var result = thread.ToPullRequestDiscussionThread();

                // Then
                result.Id.ShouldBe(id);
            }
Exemplo n.º 2
0
            public void Should_Throw_If_Thread_Is_Null()
            {
                // Given
                GitPullRequestCommentThread thread = null;

                // When
                var result = Record.Exception(() => thread.ToPullRequestDiscussionThread());

                // Then
                result.IsArgumentNullException("thread");
            }
Exemplo n.º 3
0
            public void Should_Set_Correct_FilePath_If_ThreadContext_Is_Null()
            {
                // Given
                var thread =
                    new GitPullRequestCommentThread
                {
                    Id            = 123,
                    Status        = CommentThreadStatus.Active,
                    ThreadContext = null,
                    Comments      = new List <Comment>(),
                    Properties    = new PropertiesCollection()
                };

                // When
                var result = thread.ToPullRequestDiscussionThread();

                // Then
                result.AffectedFileRelativePath.ShouldBeNull();
            }
Exemplo n.º 4
0
            public void Should_Throw_If_Properties_Are_Null()
            {
                // Given
                var thread =
                    new GitPullRequestCommentThread
                {
                    Id            = 123,
                    Status        = CommentThreadStatus.Active,
                    ThreadContext = new CommentThreadContext {
                        FilePath = "/foo.cs"
                    },
                    Comments   = new List <Comment>(),
                    Properties = null
                };

                // When
                var result = Record.Exception(() => thread.ToPullRequestDiscussionThread());

                // Then
                result.IsInvalidOperationException("Properties collection is not created.");
            }
Exemplo n.º 5
0
            public void Should_Set_Correct_Comments()
            {
                // Given
                var id               = 123;
                var status           = CommentThreadStatus.Active;
                var filePath         = "/foo.cs";
                var commentContent   = "foo";
                var commentIsDeleted = false;
                var thread           =
                    new GitPullRequestCommentThread
                {
                    Id            = id,
                    Status        = status,
                    ThreadContext = new CommentThreadContext()
                    {
                        FilePath = filePath
                    },
                    Comments = new List <Comment>
                    {
                        new Comment()
                        {
                            Content   = commentContent,
                            IsDeleted = commentIsDeleted
                        }
                    },
                    Properties = new PropertiesCollection()
                };

                // When
                var result = thread.ToPullRequestDiscussionThread();

                // Then
                result.Comments.Count.ShouldBe(1);
                result.Comments.Single().Content.ShouldBe(commentContent);
                result.Comments.Single().IsDeleted.ShouldBe(commentIsDeleted);
            }
Exemplo n.º 6
0
            public void Should_Set_Correct_FilePath(string filePath, string expectedResult)
            {
                // Given
                var id     = 123;
                var status = CommentThreadStatus.Active;
                var thread =
                    new GitPullRequestCommentThread
                {
                    Id            = id,
                    Status        = status,
                    ThreadContext = new CommentThreadContext()
                    {
                        FilePath = filePath
                    },
                    Comments   = new List <Comment>(),
                    Properties = new PropertiesCollection()
                };

                // When
                var result = thread.ToPullRequestDiscussionThread();

                // Then
                result.AffectedFileRelativePath.ToString().ShouldBe(expectedResult);
            }