public InMemoryCacheProviderBuilder_tests() { this.builder = new InMemoryCacheProviderBuilder(); }
private static IScopedClientFactory InitializeClient(object initialConfiguration, string configurationFileRoot, ICacheProviderBuilder cacheProviderBuilder, ILogger logger) { // Construct base client var clientBuilder = Clients.Builder() #if NET45 .SetHttpClient(HttpClients.Create().RestSharpClient()) #else .SetHttpClient(HttpClients.Create().SystemNetHttpClient()) #endif .SetSerializer(Serializers.Create().JsonNetSerializer()) .SetConfiguration(initialConfiguration) .SetConfigurationFileRoot(configurationFileRoot) .SetLogger(logger); if (cacheProviderBuilder != null) { clientBuilder.SetCacheProviderBuilder(cacheProviderBuilder); } var baseClient = clientBuilder.Build(); // Attempt to connect and prime the cache with ITenant try { var tenant = baseClient.GetCurrentTenant(); if (string.IsNullOrEmpty(tenant?.Href)) { throw new InitializationException("Could not connect to Stormpath. No tenant could be found."); } logger.Info($"Using tenant {tenant.Key}", nameof(InitializeClient)); } catch (Exception ex) { throw new InitializationException( "Unable to initialize the Stormpath client. See the inner exception for details.", ex); } // Scope it! return(new ScopedClientFactory(baseClient)); }