Пример #1
0
        /// <summary>
        /// Gets the achievements.
        /// </summary>
        /// <returns>The achievements.</returns>
        /// <param name="account">The developer account at issuer.</param>
        public override IList <Achievement> GetAchievements(DeveloperAccountAtIssuer account)
        {
            var achievements = new List <Achievement> ();
            var userName     = account.Username;
            var user         = GetUser(userName);

            if (user != null)
            {
                var repoRepository = new RepositoryRepository(m_requestProxy);
                var repos          = repoRepository.List(userName);
                var ownRepos       = repos.Where(r => !r.Fork && r.Owner.Login.Equals(userName, StringComparison.OrdinalIgnoreCase));

                Func <string, GitHubAchievementBuilder> c = (name) => new GitHubAchievementBuilder(name, account, Issuer);
                Action <Achievement> a = (achievement) => achievements.Add(achievement);

                a(c("Followers").User(user).Property(u => u.Followers).Link("/followers"));
                a(c("Own repositories").Repos(ownRepos).Count().Link("?tab=repositories"));

                a(c("Own repositories forks").Repos(ownRepos).Sum(r => r.Forks).Link("?tab=repositories"));
                a(c("Max single own repository forks").Repos(ownRepos).Max(r => r.ForksCount).LinkMax("/{0}/network/members", r => r.Name));

                a(c("Own repositories stars").Repos(ownRepos).Sum(r => r.StargazersCount).Link("?tab=repositories"));
                a(c("Max single own repository stars").Repos(ownRepos).Max(r => r.StargazersCount).LinkMax("/{0}/stargazers", r => r.Name));
            }

            return(achievements);
        }
Пример #2
0
        public void CanListUsersRepositories()
        {
            var repos = _repoApi.List("RhysC").ToArray();

            Assert.NotNull(repos);
            Assert.IsNotEmpty(repos);
            Assert.IsNotEmpty(repos.Where(t => t.Name == "GithubSharp").ToArray());
        }