public async Task GetPullRequestsPage_ShouldCallCorrectUrlAndResult() { var responseJson = Utilities.LoadFile(Paths.GetStandardDataPath("GetPullRequestsPageResponse.json")); var responseData = new NewtonsoftJsonSerializer().Deserialize <IteratorBasedPage <PullRequest> >(responseJson); var response = MockRepository.GenerateMock <IRestResponse <IteratorBasedPage <PullRequest> > >(); response.Stub(x => x.Data).Return(responseData); var result = _restClient .Capture() .Args <IRestRequest, IRestResponse <IteratorBasedPage <PullRequest> > >( (s, req) => s.ExecuteTaskAsync <IteratorBasedPage <PullRequest> >(req), response); var resultData = await _sut.GetPullRequestsPage("repoName", "owner", 2); Assert.AreEqual(1, result.CallCount); var args = result.Args[0]; Assert.Multiple(() => { Assert.AreEqual("repositories/owner/repoName/pullrequests", args.Resource); Assert.AreEqual(Method.GET, args.Method); var pageLen = args.Parameters.First(x => x.Name == "pagelen").Value; var page = args.Parameters.First(x => x.Name == "page").Value; Assert.AreEqual("50", pageLen); Assert.AreEqual("2", page); Assert.AreEqual(3, resultData.Values.Count); Assert.AreEqual(1, resultData.Page); Assert.AreEqual(3, resultData.Size); Assert.AreEqual(null, resultData.Next); Assert.AreEqual(50, resultData.PageLen); var firstPq = resultData.Values.First(); Assert.AreEqual("short description", firstPq.Description); Assert.AreEqual("testbranch1122", firstPq.Title); }); }