예제 #1
0
        public void UseGlobalHttpClientCache_True_NoFactory()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.HttpClientFactory = null;

            Assert.True(UseGlobalHttpClientCache(clientConfig));
        }
        public void NoFactory_NoCache()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.CacheHttpClient = false;

            RunTest(clientConfig, 1, false, false, null, null);
        }
예제 #3
0
        public void UseGlobalHttpClientCache_False_Factory()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.HttpClientFactory = new MyAdvancedClientFactory(true, false, null);

            Assert.False(UseGlobalHttpClientCache(clientConfig));
        }
예제 #4
0
        public void CreateConfigUniqueString_BasicFactory()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.HttpClientFactory = new MyBasicClientFactory();

            Assert.Equal(null, CreateConfigUniqueString(clientConfig));
        }
예제 #5
0
        public void UseGlobalHttpClientCache_True_Factory()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.HttpClientFactory = new MyAdvancedClientFactory(true, false, "abcxyz");

            Assert.True(UseGlobalHttpClientCache(clientConfig));
        }
예제 #6
0
        public void CreateConfigUniqueString_AdvancedFactory()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.HttpClientFactory = new MyAdvancedClientFactory(true, true, "abcxyz");

            Assert.Equal("abcxyz", CreateConfigUniqueString(clientConfig));
        }
예제 #7
0
        public void DisposeHttpClients_True_NoFactory()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.CacheHttpClient   = false;
            clientConfig.HttpClientFactory = null;

            Assert.True(DisposeHttpClients(clientConfig));
        }
예제 #8
0
        public void CacheHttpClients_True_AdvancedFactory()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.CacheHttpClient   = false; // make sure this is ignored
            clientConfig.HttpClientFactory = new MyAdvancedClientFactory(true, false, null);

            Assert.True(CacheHttpClients(clientConfig));
        }
예제 #9
0
        public void CacheHttpClients_True_BasicFactory()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.CacheHttpClient   = true;
            clientConfig.HttpClientFactory = new MyBasicClientFactory();

            Assert.True(CacheHttpClients(clientConfig));
        }
예제 #10
0
        public void CacheHttpClients_False_BasicFactory()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.CacheHttpClient   = false;
            clientConfig.HttpClientFactory = new MyBasicClientFactory();

            Assert.False(CacheHttpClients(clientConfig));
        }
예제 #11
0
        public void UseGlobalHttpClientCache_False_NoFactory2()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.HttpClientFactory = null;
            clientConfig.SetWebProxy(new MyWebProxy());

            Assert.False(UseGlobalHttpClientCache(clientConfig));
        }
예제 #12
0
        public void UseGlobalHttpClientCache_False_NoFactory1()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.HttpClientFactory = null;
            clientConfig.ProxyCredentials  = new MyCredentials();

            Assert.False(UseGlobalHttpClientCache(clientConfig));
        }
예제 #13
0
        public void CreateConfigUniqueString_NoFactory()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.HttpClientCacheSize = 1234321;
            clientConfig.HttpClientFactory   = null;

            Assert.Equal("AllowAutoRedirect:TrueCacheSize:1234321", CreateConfigUniqueString(clientConfig));
        }
        public void NoFactory_GlobalCache()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.CacheHttpClient     = true;
            clientConfig.HttpClientCacheSize = DefaultHttpCacheSize;

            RunTest(clientConfig, 1, true, true, DefaultHttpCacheSize, "AllowAutoRedirect:TrueCacheSize:" + DefaultHttpCacheSize);
        }
        public void NoFactory_LocalCache()
        {
            var clientConfig = new MyClientConfig();

            clientConfig.CacheHttpClient     = true;
            clientConfig.HttpClientCacheSize = DefaultHttpCacheSize;
            clientConfig.SetWebProxy(new MyWebProxy()); // force local cache

            RunTest(clientConfig, 1, true, false, DefaultHttpCacheSize, null);
        }
        public void WithFactory_SDKLocalCache()
        {
            var clientConfig    = new MyClientConfig();
            var myClientFactory = new MyAdvancedClientFactory(true, false, null);

            clientConfig.HttpClientCacheSize = DefaultHttpCacheSize;
            clientConfig.HttpClientFactory   = myClientFactory;

            RunTest(clientConfig, DefaultHttpCacheSize * 2, true, false, DefaultHttpCacheSize, null);
            Assert.Equal(DefaultHttpCacheSize, myClientFactory.UncachedClients.Count);
        }
        public void WithFactory_SDKGlobalCache()
        {
            var configUniqueString = Guid.NewGuid().ToString();
            var clientConfig       = new MyClientConfig();
            var myClientFactory    = new MyAdvancedClientFactory(true, false, configUniqueString);

            clientConfig.HttpClientCacheSize = DefaultHttpCacheSize;
            clientConfig.HttpClientFactory   = myClientFactory;

            RunTest(clientConfig, DefaultHttpCacheSize * 2, true, true, DefaultHttpCacheSize, configUniqueString);
            Assert.Equal(DefaultHttpCacheSize, myClientFactory.UncachedClients.Count);
        }
        public void WithFactory_ExternalCache()
        {
            var clientConfig    = new MyClientConfig();
            var myClientFactory = new MyAdvancedClientFactory(false, false, null);

            clientConfig.HttpClientCacheSize = DefaultHttpCacheSize;
            clientConfig.HttpClientFactory   = myClientFactory;

            RunTest(clientConfig, 1, false, false, null, null);
            var actualCacheSize = ((HttpClient[])ReflectionHelpers.Invoke(myClientFactory.ClientCache, "_clients")).Length;

            Assert.Equal(DefaultHttpCacheSize, actualCacheSize);
        }