Пример #1
0
        public async Task GetPullRequestComments_ShouldCallCorrectUrlAndGetResult()
        {
            var responseJson = Utilities.LoadFile(Paths.GetEnterpriseDataPath("GetPullRequestCommentsResponse.json"));
            var responseData = new NewtonsoftJsonSerializer().Deserialize <EnterpriseIteratorBasedPage <EnterpriseCommentActivity> >(responseJson);

            var result = _restClient
                         .Capture()
                         .Args <string, int, QueryString, IEnumerable <EnterpriseCommentActivity> >((s, url, limit, queryString) => s.GetAllPages <EnterpriseCommentActivity>(url, limit, queryString), responseData.Values);

            var resultData = (await _sut.GetPullRequestComments("reponame", "owner", 1)).ToList();

            Assert.AreEqual(1, result.CallCount);

            var args = result.Args[0];

            Assert.Multiple(() =>
            {
                Assert.AreEqual("projects/owner/repos/reponame/pull-requests/1/activities", args.arg1);
                Assert.AreEqual(50, args.arg2);
                Assert.IsNull(args.arg3);

                var secondComment = resultData[1];

                Assert.AreEqual("ReplyComment", secondComment.Content.Html);
                Assert.AreEqual(null, secondComment.Content.Raw);
                Assert.AreEqual("05/14/2017 15:52:59", secondComment.CreatedOn);
                Assert.AreEqual(63, secondComment.Id);
                Assert.AreEqual(null, secondComment.Inline);
                Assert.AreEqual("05/14/2017 15:52:59", secondComment.UpdatedOn);
                Assert.AreEqual("MistyKuuuuuuuu", secondComment.User.DisplayName);
                Assert.AreEqual(62, secondComment.Parent.Id);
            });
        }