Exemplo n.º 1
0
            public void Should_Call_InternalFetchDiscussionThreads()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);
                var settings          = new ReportIssuesToPullRequestSettings(@"c:\repo");
                var discussionThreads =
                    new List <IPullRequestDiscussionThread>
                {
                    new PullRequestDiscussionThread(
                        1,
                        PullRequestDiscussionStatus.Active,
                        new FilePath(@"src\Cake.Issues.Tests\FakeIssueProvider.cs"),
                        new List <IPullRequestDiscussionComment>
                    {
                        new PullRequestDiscussionComment()
                        {
                            Content   = "Message Foo",
                            IsDeleted = false
                        }
                    })
                    {
                        CommentSource = settings.CommentSource,
                    }
                };
                var capability = new FakeDiscussionThreadsCapability(log, pullRequestSystem, discussionThreads);

                // When
                pullRequestSystem.Initialize(settings);
                var result = capability.FetchDiscussionThreads(settings.CommentSource);

                // Then
                result.ShouldBe(discussionThreads);
            }
            public void Should_Call_InternalResolveDiscussionThreads()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);
                var settings          = new ReportIssuesToPullRequestSettings(@"c:\repo");
                var discussionThread1 =
                    new PullRequestDiscussionThread(
                        1,
                        PullRequestDiscussionStatus.Active,
                        new FilePath(@"src\Cake.Issues.Tests\Foo.cs"),
                        new List <IPullRequestDiscussionComment>
                {
                    new PullRequestDiscussionComment()
                    {
                        Content   = "Message Foo",
                        IsDeleted = false
                    }
                })
                {
                    CommentIdentifier = "Message Foo",
                    CommentSource     = settings.CommentSource,
                };
                var discussionThread2 =
                    new PullRequestDiscussionThread(
                        1,
                        PullRequestDiscussionStatus.Active,
                        new FilePath(@"src\Cake.Issues.Tests\Bar.cs"),
                        new List <IPullRequestDiscussionComment>
                {
                    new PullRequestDiscussionComment()
                    {
                        Content   = "Message Bar",
                        IsDeleted = false
                    }
                })
                {
                    CommentIdentifier = "Message Bar",
                    CommentSource     = settings.CommentSource,
                };
                var discussionThreads =
                    new List <IPullRequestDiscussionThread>
                {
                    discussionThread1, discussionThread2
                };
                var capability = new FakeDiscussionThreadsCapability(log, pullRequestSystem, discussionThreads);

                // When
                pullRequestSystem.Initialize(settings);
                capability.ResolveDiscussionThreads(
                    new List <IPullRequestDiscussionThread>
                {
                    discussionThread1
                });

                // Then
                capability.ResolvedThreads.ShouldContain(discussionThread1);
            }
Exemplo n.º 3
0
            public void Should_Set_Log()
            {
                // Given
                var log = new FakeLog();

                // When
                var pullRequestSystem = new FakePullRequestSystem(log);

                // Then
                pullRequestSystem.Log.ShouldBe(log);
            }
Exemplo n.º 4
0
            public void Should_Return_PlainText()
            {
                // Given
                var pullRequestSystem = new FakePullRequestSystem(new FakeLog());

                // When
                var result = pullRequestSystem.GetPreferredCommentFormat();

                // Then
                result.ShouldBe(IssueCommentFormat.PlainText);
            }
Exemplo n.º 5
0
            public void Should_Throw_If_Settings_Is_Null()
            {
                // Given
                var pullRequestSystem = new FakePullRequestSystem(new FakeLog());

                // When
                var result = Record.Exception(() => pullRequestSystem.PostDiscussionThreads(new List <IIssue>(), "Foo"));

                // Then
                result.IsInvalidOperationException("Initialize needs to be called first.");
            }
            public void Should_Throw_If_PullRequestSystem_Is_Null()
            {
                // Given
                var log = new FakeLog();
                FakePullRequestSystem pullRequestSystem = null;

                // When
                var result = Record.Exception(() => new FakeCheckingCommitIdCapability(log, pullRequestSystem));

                // Then
                result.IsArgumentNullException("pullRequestSystem");
            }
Exemplo n.º 7
0
            public void Should_Throw_If_Log_Is_Null()
            {
                // Given
                ICakeLog log = null;
                var      pullRequestSystem = new FakePullRequestSystem(new FakeLog());

                // When
                var result = Record.Exception(() => new FakePullRequestSystemCapability(log, pullRequestSystem));

                // Then
                result.IsArgumentNullException("log");
            }
            public void Should_Set_PullRequestSystem()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);

                // When
                var capability = new FakeCheckingCommitIdCapability(log, pullRequestSystem);

                // Then
                capability.PullRequestSystem.ShouldBe(pullRequestSystem);
            }
Exemplo n.º 9
0
            public void Should_Set_Log()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);

                // When
                var capability = new FakePullRequestSystemCapability(log, pullRequestSystem);

                // Then
                capability.Log.ShouldBe(log);
            }
Exemplo n.º 10
0
            public void Should_Set_PullRequestSystem()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);
                var modifiedFiles     = new List <FilePath>();

                // When
                var capability = new FakeFilteringByModifiedFilesCapability(log, pullRequestSystem, modifiedFiles);

                // Then
                capability.PullRequestSystem.ShouldBe(pullRequestSystem);
            }
Exemplo n.º 11
0
            public void Should_Set_PullRequestSystem()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);
                var discussionThreads = new List <IPullRequestDiscussionThread>();

                // When
                var capability = new FakeDiscussionThreadsCapability(log, pullRequestSystem, discussionThreads);

                // Then
                capability.PullRequestSystem.ShouldBe(pullRequestSystem);
            }
Exemplo n.º 12
0
            public void Should_Return_False_If_PullRequestSystem_Does_Not_Have_Capability()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);
                var capability        = new FakePullRequestSystemCapability(log, pullRequestSystem);

                // When
                pullRequestSystem.AddCapability(capability);

                // Then
                pullRequestSystem.HasCapability <FakeCheckingCommitIdCapability>().ShouldBeFalse();
            }
Exemplo n.º 13
0
            public void Should_Return_True_If_PullRequestSystem_Has_Capability()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);
                var capability        = new FakePullRequestSystemCapability(log, pullRequestSystem);

                // When
                pullRequestSystem.AddCapability(capability);

                // Then
                pullRequestSystem.HasCapability <FakePullRequestSystemCapability>().ShouldBeTrue();
            }
Exemplo n.º 14
0
            public void Should_Throw_If_Capability_Is_Null()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);
                IPullRequestSystemCapability capability = null;

                // When
                var result = Record.Exception(() => pullRequestSystem.AddCapability(capability));

                // Then
                result.IsArgumentNullException("capability");
            }
Exemplo n.º 15
0
            public void Should_Throw_If_PullRequestSystem_Is_Null()
            {
                // Given
                var log = new FakeLog();
                FakePullRequestSystem pullRequestSystem = null;
                var modifiedFiles = new List <FilePath>();

                // When
                var result =
                    Record.Exception(() =>
                                     new FakeFilteringByModifiedFilesCapability(log, pullRequestSystem, modifiedFiles));

                // Then
                result.IsArgumentNullException("pullRequestSystem");
            }
Exemplo n.º 16
0
            public void Should_Throw_If_PullRequestSystem_Is_Null()
            {
                // Given
                var log = new FakeLog();
                FakePullRequestSystem pullRequestSystem = null;
                var discussionThreads = new List <IPullRequestDiscussionThread>();

                // When
                var result =
                    Record.Exception(() =>
                                     new FakeDiscussionThreadsCapability(log, pullRequestSystem, discussionThreads));

                // Then
                result.IsArgumentNullException("pullRequestSystem");
            }
Exemplo n.º 17
0
            public void Should_Return_Capability_If_Capability_Exists()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);
                var capability        = new FakePullRequestSystemCapability(log, pullRequestSystem);

                pullRequestSystem.AddCapability(capability);

                // When
                var result = pullRequestSystem.GetCapability <FakePullRequestSystemCapability>();

                // Then
                result.ShouldBe(capability);
            }
Exemplo n.º 18
0
            public void Should_Return_Null_If_Capability_Does_Not_Exist()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);
                var capability        = new FakePullRequestSystemCapability(log, pullRequestSystem);

                pullRequestSystem.AddCapability(capability);

                // When
                var result = pullRequestSystem.GetCapability <FakeCheckingCommitIdCapability>();

                // Then
                result.ShouldBeNull();
            }
Exemplo n.º 19
0
            public void Should_Throw_If_Not_Initialized()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);
                var modifiedFiles     = new List <FilePath>();
                var capability        = new FakeFilteringByModifiedFilesCapability(log, pullRequestSystem, modifiedFiles);

                // When
                var result =
                    Record.Exception(() =>
                                     capability.GetModifiedFilesInPullRequest());

                // Then
                result.IsInvalidOperationException("Initialize needs to be called first.");
            }
Exemplo n.º 20
0
            public void Should_Throw_If_Not_Initialized()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);
                var discussionThreads = new List <IPullRequestDiscussionThread>();
                var capability        = new FakeDiscussionThreadsCapability(log, pullRequestSystem, discussionThreads);

                // When
                var result =
                    Record.Exception(() =>
                                     capability.FetchDiscussionThreads("foo"));

                // Then
                result.IsInvalidOperationException("Initialize needs to be called first.");
            }
Exemplo n.º 21
0
            public void Should_Call_InternalGetModifiedFilesInPullRequest()
            {
                // Given
                var log = new FakeLog();
                var pullRequestSystem = new FakePullRequestSystem(log);
                var settings          = new ReportIssuesToPullRequestSettings(@"c:\repo");
                var modifiedFiles     = new List <FilePath> {
                    @"foo.cs"
                };
                var capability = new FakeFilteringByModifiedFilesCapability(log, pullRequestSystem, modifiedFiles);

                // When
                pullRequestSystem.Initialize(settings);
                var result = capability.GetModifiedFilesInPullRequest();

                // Then
                result.ShouldBe(modifiedFiles);
            }
Exemplo n.º 22
0
        /// <summary>
        /// Creates a new <see cref="FakePullRequestSystem"/>.
        /// </summary>
        /// <returns>New pull request system.</returns>
        public FakePullRequestSystem Create()
        {
            var pullRequestSystem = new FakePullRequestSystem(this.log);

            if (this.withCheckingCommitIdCapability)
            {
                pullRequestSystem.AddCapability(
                    new FakeCheckingCommitIdCapability(this.log, pullRequestSystem));
            }

            if (this.withDiscussionThreadsCapability)
            {
                pullRequestSystem.AddCapability(
                    new FakeDiscussionThreadsCapability(this.log, pullRequestSystem, this.discussionThreads));
            }

            if (this.withFilteringByModifiedFilesCapability)
            {
                pullRequestSystem.AddCapability(
                    new FakeFilteringByModifiedFilesCapability(this.log, pullRequestSystem, this.modifiedFiles));
            }

            return(pullRequestSystem);
        }