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

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

            var resultData = (await _sut.GetPullRequestForBranches("reponame", "owner", "hhhhhhhhhhhhhhhh", "12"));

            Assert.AreEqual(1, result.CallCount);

            var args = result.Args[0];

            Assert.Multiple(() =>
            {
                Assert.AreEqual("projects/owner/repos/reponame/pull-requests", args.arg1);
                Assert.AreEqual(50, args.arg2);
                Assert.AreEqual("?at=refs/heads/12&state=open", args.arg3.ToString());

                Assert.AreEqual("* asd\r\n* asd", resultData.Description);
                Assert.AreEqual("hhhhhhhhhhhhhhhh", resultData.Title);
                Assert.AreEqual("refs/heads/hhhhhhhhhhhhhhhh", resultData.Source.Branch.Name);
                Assert.AreEqual("refs/heads/12", resultData.Destination.Branch.Name);
            });
        }