public void ReturnsFalseWhenWeHaveNotRequestedRepository() { var gitHubHost = HostAddress.GitHubDotComHostAddress; var gitHubClient = Substitute.For<IGitHubClient>(); 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 = client.IsEnterprise(); Assert.False(result); }
public async Task ReturnsTrueWhenEnterpriseProbeReturnsOk(EnterpriseProbeResult 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>(); enterpriseProbe.ProbeAsync(Args.Uri) .Returns(_ => Task.FromResult(probeResult), _ => { throw new Exception("Only call it once"); }); 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 = client.IsEnterprise(); Assert.Equal(expected, result); Assert.Equal(expected, client.IsEnterprise()); }