GitHub.Api.SimpleApiClient.GetRepository C# (CSharp) Method

GetRepository() public method

public GetRepository ( ) : Task
return Task
        public async Task<Repository> GetRepository()
        {
            // fast path to avoid locking when the cache has already been set
            // once it's been set, it's never going to be touched again, so it's safe
            // to read. This way, lock queues will only form once on first load
            if (owner != null)
                return repositoryCache;
            return await GetRepositoryInternal();
        }
        

Usage Example

        public async Task RetrievesCachedRepositoryForSubsequentCalls()
        {
            var gitHubHost = HostAddress.GitHubDotComHostAddress;
            var gitHubClient = Substitute.For<IGitHubClient>();
            var repository = new Repository(42);
            gitHubClient.Repository.Get("github", "visualstudio")
                .Returns(_ => Task.FromResult(repository), _ => { throw new Exception("Should only be called once."); });
            var enterpriseProbe = Substitute.For<IEnterpriseProbeTask>();
            var wikiProbe = Substitute.For<IWikiProbe>();
            var client = new SimpleApiClient(
                "https://github.com/github/visualstudio",
                gitHubClient,
                new Lazy<IEnterpriseProbeTask>(() => enterpriseProbe),
                new Lazy<IWikiProbe>(() => wikiProbe));
            await client.GetRepository();

            var result = await client.GetRepository();

            Assert.Equal(42, result.Id);
        }
All Usage Examples Of GitHub.Api.SimpleApiClient::GetRepository