示例#1
0
        public async void ShouldSaveCommentsBeforeRetrieveDiff()
        {
            await _mainWindowVm.RetrieveDiffs();

            _commentsPersist.ClearReceivedCalls();

            var pr = PullRequestLocator.FromUrl("https://github.com/owner/newrepo1/pull/122");

            _mainWindowVm.PullRequestLocator = pr;
            var expectedCommentsContainer = CommentsContainer.From(_mainWindowVm.Diffs, _mainWindowVm.GeneralComments);

            try
            {
                await _mainWindowVm.RetrieveDiffs();
            }
            catch
            {
                // ignored
            }

            _commentsPersist.Received(1)
            .Save(_pullRequestLocator,
                  Arg.Is <CommentsContainer>(x => x.Equals(expectedCommentsContainer)))
            .IgnoreAsyncWarning();
        }
示例#2
0
        public async void CanSaveComments()
        {
            var expectedCommentsContainer = CommentsContainer.From(_mainWindowVm.Diffs, _mainWindowVm.GeneralComments);
            await _mainWindowVm.SaveComments();

            _commentsPersist.Received(1)
            .Save(_pullRequestLocator, Arg.Is <CommentsContainer>(x => x.Equals(expectedCommentsContainer)))
            .IgnoreAsyncWarning();
        }
示例#3
0
        void resetMLOComments()
        {
            _isCircleSelected = false;
            MLOCommentsGrid.Children.Clear();
            BarTarea.Source = new BitmapImage(new Uri("ms-appx:///Resources/muro/tareas/barra_unidad.png"));
            CommentsContainer comm_byList = new CommentsContainer();

            comm_byList.LOCommentsList = (ViewModel as MainViewModel).LOCommentsList;
            MLOCommentsGrid.Children.Add(comm_byList);
            MLOCommentsGrid.Visibility    = Visibility.Visible;
            CircleCommentsGrid.Visibility = Visibility.Collapsed;
            CommentsRing.Visibility       = Visibility.Collapsed;
        }
        private void load(CancellationToken?cancellation, IAPIProvider api, OverlayColourProvider colourProvider)
        {
            bool complete = false;

            var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);

            req.Success += res =>
            {
                build    = res;
                complete = true;
            };
            req.Failure += _ => complete = true;

            api.PerformAsync(req);

            while (!complete)
            {
                if (cancellation?.IsCancellationRequested == true)
                {
                    req.Cancel();
                    return;
                }

                Thread.Sleep(10);
            }

            if (build != null)
            {
                CommentsContainer comments;

                Children = new Drawable[]
                {
                    new ChangelogBuildWithNavigation(build)
                    {
                        SelectBuild = SelectBuild
                    },
                    new Box
                    {
                        RelativeSizeAxes = Axes.X,
                        Height           = 2,
                        Colour           = colourProvider.Background6,
                        Margin           = new MarginPadding {
                            Top = 30
                        },
                    },
                    comments = new CommentsContainer()
                };

                comments.ShowComments(CommentableType.Build, build.Id);
            }
        }
示例#5
0
        private async Task SaveCommentsWithoutChangeBusyStatus(PullRequestLocator request)
        {
            if (request == null || !request.IsValid())
            {
                return;
            }
            var commentsContainer = _loadedComments;

            if (_loadedComments != null)
            {
                commentsContainer.AddComments(Diffs.ToList(), GeneralComments);
            }
            else
            {
                commentsContainer = CommentsContainer.From(Diffs, GeneralComments);
            }
            await _commentsPersist.Save(request, commentsContainer);
        }
        public void HappyPath()
        {
            var diffs = new List <CommitFileVm>()
            {
                _file1,
                _file2
            };
            var container = CommentsContainer.From(diffs, "general comments");

            Assert.That(container.GeneralComments, Is.EqualTo("general comments"));
            Assert.That(container.FileComments[0].Comments, Is.EqualTo("Comment1"));
            Assert.That(container.FileComments[0].FileName, Is.EqualTo("File1"));
            Assert.That(container.FileComments[0].ReviewStatus, Is.EqualTo(ReviewStatus.Reviewed));

            Assert.That(container.FileComments[1].Comments, Is.EqualTo("Comment2"));
            Assert.That(container.FileComments[1].FileName, Is.EqualTo("File2"));
            Assert.That(container.FileComments[1].ReviewStatus, Is.EqualTo(ReviewStatus.HasntBeenReviewed));
        }
示例#7
0
            public CommentsSection()
            {
                CommentsContainer comments;

                Add(comments = new CommentsContainer());

                BeatmapSet.BindValueChanged(beatmapSet =>
                {
                    if (beatmapSet.NewValue?.OnlineBeatmapSetID is int onlineBeatmapSetID)
                    {
                        Show();
                        comments.ShowComments(CommentableType.Beatmapset, onlineBeatmapSetID);
                    }
                    else
                    {
                        Hide();
                    }
                }, true);
            }
        public void ShouldNotSkipEmptyComments_AsWeNeedToSaveReviewStatus()
        {
            var diffs = new List <CommitFileVm>
            {
                _file1,
                _file2,
                _file3
            };

            _file2.Comments = "";
            var container = CommentsContainer.From(diffs, "general comments");

            container.FileComments[1].Comments.ShouldBeNullOrEmpty();
            container.FileComments[1].FileName.ShouldBe("File2");

            container.FileComments.Count.ShouldBe(3);

            container.FileComments[2].Comments.ShouldBeNullOrEmpty();
            container.FileComments[2].FileName.ShouldBe("File3");
        }
示例#9
0
        public TestSceneCommentsContainer()
        {
            BasicScrollContainer scroll;
            CommentsContainer    comments;

            Add(scroll = new BasicScrollContainer
            {
                RelativeSizeAxes = Axes.Both,
                Child            = comments = new CommentsContainer()
            });

            AddStep("Big Black comments", () => comments.ShowComments(CommentableType.Beatmapset, 41823));
            AddStep("Airman comments", () => comments.ShowComments(CommentableType.Beatmapset, 24313));
            AddStep("Lazer build comments", () => comments.ShowComments(CommentableType.Build, 4772));
            AddStep("News comments", () => comments.ShowComments(CommentableType.NewsPost, 715));
            AddStep("Idle state", () =>
            {
                scroll.Clear();
                scroll.Add(comments = new CommentsContainer());
            });
        }
        public void AbleToAddComments_SoCommentsWillBeKept_WhenUserChangeCommitRange()
        {
            var diffs = new List <CommitFileVm>()
            {
                _file1,
                _file2,
            };

            var container = CommentsContainer.From(diffs, "general comments");

            var commentsInCommitRange = new List <CommitFileVm>
            {// _file2 is not in commit range, _file3 is new.
                _file1,
                _file3
            };

            container.AddComments(commentsInCommitRange, "new general comments");
            container.GeneralComments.ShouldBe("new general comments");
            container.FileComments.ShouldContain(x => x.FileName == _file1.GitHubCommitFile.Filename);
            container.FileComments.ShouldContain(x => x.FileName == _file2.GitHubCommitFile.Filename);
            container.FileComments.ShouldContain(x => x.FileName == _file3.GitHubCommitFile.Filename);
            container.FileComments.ShouldContain(x => x.Comments == _file3.Comments);
        }
 public void SetUp() => Schedule(() =>
                                 Child = new BasicScrollContainer
 {
     RelativeSizeAxes = Axes.Both,
     Child            = commentsContainer = new CommentsContainer()
 });
示例#12
0
        public void SetUp()
        {
            _compareResults       = new MockCompareResult();
            _gitHubClient         = Substitute.For <IGitHubClient>();
            _repoClient           = Substitute.For <IRepositoriesClient>();
            _commitsClient        = Substitute.For <IRepositoryCommitsClient>();
            _prClient             = Substitute.For <IPullRequestsClient>();
            _contentsClient       = Substitute.For <IRepositoryContentsClient>();
            _fileContentPersist   = Substitute.For <IFileContentPersist>();
            _diffTool             = Substitute.For <IDiffToolLauncher>();
            _patchService         = Substitute.For <IPatchService>();
            _reviewClient         = Substitute.For <IIssueCommentsClient>();
            _commentsBuilder      = Substitute.For <ICommentsBuilder>();
            _commentsPersist      = Substitute.For <ICommentsPersist>();
            _repoHistoryPersist   = Substitute.For <IRepoHistoryPersist>();
            _backgroundTaskRunner = Substitute.For <IBackgroundTaskRunner>();
            var userManager = Substitute.For <IUserManager>();

            _gitHubClient.Repository.Returns(_repoClient);
            _repoClient.Commit.Returns(_commitsClient);
            _repoClient.PullRequest.Returns(_prClient);
            _repoClient.Content.Returns(_contentsClient);
            _gitHubClient.Issue.Comment.Returns(_reviewClient);

            _commitsClient.Compare(Arg.Any <string>(),
                                   Arg.Any <string>(),
                                   Arg.Any <string>(),
                                   Arg.Any <string>()
                                   ).Returns(Task.FromResult((CompareResult)_compareResults));

            _mainWindowVm = new MainWindowVm(_gitHubClient, _fileContentPersist,
                                             _diffTool, _patchService, _commentsBuilder,
                                             _commentsPersist, _repoHistoryPersist, _backgroundTaskRunner, userManager)
            {
                PullRequestLocator = _pullRequestLocator,
                IsUrlMode          = false
            };

            _pullRequest = new MockPullRequest {
                Number = _pullRequestLocator.PullRequestNumber
            };
            _prClient.Get(_mainWindowVm.PullRequestLocator.Owner, _mainWindowVm.PullRequestLocator.Repository,
                          _mainWindowVm.PullRequestLocator.PullRequestNumber).Returns(Task.FromResult((PullRequest)_pullRequest));

            _baseFileName = MainWindowVm.BuildBaseFileName(_pullRequest.Base.Sha, _compareResults.File1.Filename);
            _headFileName = MainWindowVm.BuildHeadFileName(_pullRequest.Head.Sha, _compareResults.File1.Filename);

            _commentsContainer = new CommentsContainer {
                GeneralComments = GeneralComments
            };
            _commentsContainer.FileComments.Add(new FileComment
            {
                FileName     = _compareResults.File1.Filename,
                Comments     = Comment1,
                ReviewStatus = ReviewStatus1
            });
            _commentsContainer.FileComments.Add(new FileComment
            {
                FileName     = _compareResults.File2.Filename,
                Comments     = Comment2,
                ReviewStatus = ReviewStatus2
            });
            _commentsPersist.Load(Arg.Is <PullRequestLocator>(x => x.Equals(_pullRequestLocator)))
            .Returns(Task.FromResult(_commentsContainer));

            _backgroundTaskRunner.WhenForAnyArgs(x => x.RunInBackground(null)).Do(args =>
            {
                var a = args[0] as Action;
                a.Invoke();
            });

            _commentsPersist.ClearReceivedCalls();
            _backgroundTaskRunner.ClearReceivedCalls();
        }