Пример #1
0
        /// <summary>
        /// Generator that allows lazy access to paginated resources.
        /// </summary>
        /// <typeparam name="TValue"></typeparam>
        /// <param name="overrideUrl"></param>
        /// <param name="pageLen"></param>
        /// <returns></returns>
        private IEnumerable <List <TValue> > IteratePages <TValue>(string overrideUrl, int pageLen = DEFAULT_PAGE_LEN)
        {
            Debug.Assert(!String.IsNullOrEmpty(overrideUrl));
            Debug.Assert(!overrideUrl.Contains("?"));

            dynamic requestParameters = new ExpandoObject();

            requestParameters.pagelen = pageLen;

            IteratorBasedPage <TValue> response;
            int page = 1;

            do
            {
                response = _sharpBucketV2.Get(new IteratorBasedPage <TValue>(), overrideUrl.Replace(SharpBucketV2.BITBUCKET_URL, ""), requestParameters);
                if (response == null)
                {
                    break;
                }

                yield return(response.values);

                requestParameters.page = ++page;
            } while (!String.IsNullOrEmpty(response.next));
        }
        public void MockAuthentication_ShouldUseMock()
        {
            string expected = "Hello from mock";

            _client.Setup(c => c.Execute(It.IsAny <IRestRequest>()))
            .Returns(new RestResponse()
            {
                ResponseStatus = ResponseStatus.Completed,
                StatusCode     = System.Net.HttpStatusCode.OK,
                Content        = expected,
            });

            var client = new SharpBucketV2();

            client.MockAuthentication(_client.Object);
            var output = client.Get(null);

            output.ShouldBe(expected);
        }
Пример #3
0
 /// <summary>
 /// Gets the public information associated with a team.
 /// If the team's profile is private, the caller must be authenticated and authorized to view this information.
 /// </summary>
 public Team GetProfile()
 {
     return(_sharpBucketV2.Get <Team>(_baseUrl));
 }
Пример #4
0
        /// <summary>
        /// List of repositories associated with an account. If the caller is properly authenticated and authorized,
        /// this method returns a collection containing public and private repositories.
        /// Otherwise, this method returns a collection of the public repositories.
        /// </summary>
        /// <param name="accountName">The account whose repositories you wish to get.</param>
        /// <returns></returns>
        public List <Repository> ListRepositories(string accountName)
        {
            var overrideUrl = _baseUrl + accountName + "/";

            return(_sharpBucketV2.Get(new RepositoryInfo(), overrideUrl).values);
        }
Пример #5
0
 /// <summary>
 /// Get the full project object located at this resource location
 /// https://developer.atlassian.com/bitbucket/api/2/reference/resource/teams/%7Busername%7D/projects/%7Bproject_key%7D#get
 /// </summary>
 public Project GetProject()
 {
     return(SharpBucketV2.Get <Project>(ProjectUrl));
 }
Пример #6
0
 /// <summary>
 /// Gets the public information associated with a user.
 /// If the user's profile is private, the caller must be authenticated as the account holder to view this information.
 /// </summary>
 /// <returns></returns>
 public User GetProfile()
 {
     return(_sharpBucketV2.Get(new User(), _baseUrl));
 }
Пример #7
0
 /// <summary>
 /// Gets the public information associated with a team.
 /// If the team's profile is private, the caller must be authenticated and authorized to view this information.
 /// </summary>
 /// <returns></returns>
 public Team GetProfile()
 {
     return(_sharpBucketV2.Get(new Team(), _baseUrl));
 }