public void CreatesNewInstanceOfSimpleApiClient()
        {
            var program         = new Program();
            var enterpriseProbe = Substitute.For <IEnterpriseProbeTask>();
            var wikiProbe       = Substitute.For <IWikiProbe>();
            var factory         = new SimpleApiClientFactory(
                program,
                new Lazy <IEnterpriseProbeTask>(() => enterpriseProbe),
                new Lazy <IWikiProbe>(() => wikiProbe));

            var client = factory.Create("https://github.com/github/visualstudio");

            Assert.Equal("https://github.com/github/visualstudio", client.OriginalUrl);
            Assert.Equal(HostAddress.GitHubDotComHostAddress, client.HostAddress);
            Assert.Same(client, factory.Create("https://github.com/github/visualstudio")); // Tests caching.
        }
        public void RemovesClientFromCache()
        {
            var program         = new Program();
            var enterpriseProbe = Substitute.For <IEnterpriseProbeTask>();
            var wikiProbe       = Substitute.For <IWikiProbe>();
            var factory         = new SimpleApiClientFactory(
                program,
                new Lazy <IEnterpriseProbeTask>(() => enterpriseProbe),
                new Lazy <IWikiProbe>(() => wikiProbe));

            var client = factory.Create("https://github.com/github/visualstudio");

            factory.ClearFromCache(client);

            Assert.NotSame(client, factory.Create("https://github.com/github/visualstudio"));
        }
        public async Task RemovesClientFromCache()
        {
            const string url             = "https://github.com/github/RemovesClientFromCache";
            var          program         = new Program();
            var          enterpriseProbe = Substitute.For <IEnterpriseProbeTask>();
            var          wikiProbe       = Substitute.For <IWikiProbe>();
            var          factory         = new SimpleApiClientFactory(
                program,
                new Lazy <IEnterpriseProbeTask>(() => enterpriseProbe),
                new Lazy <IWikiProbe>(() => wikiProbe));

            var client = await factory.Create(url);

            factory.ClearFromCache(client);

            Assert.NotSame(client, factory.Create(url));
        }
        public async Task CreatesNewInstanceOfSimpleApiClient()
        {
            const string url             = "https://github.com/github/CreatesNewInstanceOfSimpleApiClient";
            var          program         = new Program();
            var          enterpriseProbe = Substitute.For <IEnterpriseProbeTask>();
            var          wikiProbe       = Substitute.For <IWikiProbe>();
            var          factory         = new SimpleApiClientFactory(
                program,
                new Lazy <IEnterpriseProbeTask>(() => enterpriseProbe),
                new Lazy <IWikiProbe>(() => wikiProbe));

            var client = await factory.Create(url);

            Assert.Equal(url, client.OriginalUrl);
            Assert.Equal(HostAddress.GitHubDotComHostAddress, client.HostAddress);
            Assert.Same(client, await factory.Create(url)); // Tests caching.
        }
Ejemplo n.º 5
0
        public async Task CreatesNewInstanceOfSimpleApiClient()
        {
            const string url             = "https://github.com/github/CreatesNewInstanceOfSimpleApiClient";
            var          program         = CreateProgram();
            var          keychain        = Substitute.For <IKeychain>();
            var          enterpriseProbe = Substitute.For <IEnterpriseProbe>();
            var          wikiProbe       = Substitute.For <IWikiProbe>();
            var          factory         = new SimpleApiClientFactory(
                program,
                CreateKeychain(),
                new Lazy <IEnterpriseProbe>(() => enterpriseProbe),
                new Lazy <IWikiProbe>(() => wikiProbe));

            var client = await factory.Create(url);

            Assert.That(url, Is.EqualTo(client.OriginalUrl));
            Assert.That(HostAddress.GitHubDotComHostAddress, Is.EqualTo(client.HostAddress));
            Assert.That(client, Is.SameAs(await factory.Create(url))); // Tests caching.
        }