GetRepository() public méthode

public GetRepository ( ) : Task
Résultat Task
        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);
        }
        public async Task RetrievesRepositoryFromWeb()
        {
            var gitHubHost = HostAddress.GitHubDotComHostAddress;
            var gitHubClient = Substitute.For<IGitHubClient>();
            var repository = new Repository(42);
            gitHubClient.Repository.Get("github", "visualstudio").Returns(Task.FromResult(repository));
            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));

            var result = await client.GetRepository();

            Assert.Equal(42, result.Id);
        }
        public async Task ReturnsTrueWhenWikiProbeReturnsOk(WikiProbeResult probeResult, bool expected)
        {
            var gitHubHost = HostAddress.GitHubDotComHostAddress;
            var gitHubClient = Substitute.For<IGitHubClient>();
            var repository = CreateRepository(42, true);
            gitHubClient.Repository.Get("github", "visualstudio").Returns(Task.FromResult(repository));
            var enterpriseProbe = Substitute.For<IEnterpriseProbeTask>();
            var wikiProbe = Substitute.For<IWikiProbe>();
            wikiProbe.ProbeAsync(repository)
                .Returns(_ => Task.FromResult(probeResult), _ => { throw new Exception("Only call it once"); });
            var client = new SimpleApiClient(
                gitHubHost,
                "https://github.com/github/visualstudio",
                gitHubClient,
                new Lazy<IEnterpriseProbeTask>(() => enterpriseProbe),
                new Lazy<IWikiProbe>(() => wikiProbe));
            await client.GetRepository();

            var result = client.HasWiki();

            Assert.Equal(expected, result);
            Assert.Equal(expected, client.HasWiki());
        }