private static IUnleashApiClient CreateApiClient()
        {
            var apiUri = new Uri("http://unleash.herokuapp.com/api/");

            var jsonSerializer = new DynamicNewtonsoftJsonSerializer();

            jsonSerializer.TryLoad();

            var httpClientFactory = new DefaultHttpClientFactory();

            var requestHeaders = new UnleashApiClientRequestHeaders
            {
                AppName           = "api-test-client",
                InstanceTag       = "instance1",
                CustomHttpHeaders = new Dictionary <string, string>()
                {
                    // "Test" token from 21.10.2021
                    { "Authorization", "*:default.77c45b703a681983b714fee87e575a823bfb1fd0ab282d9399647243" }
                },
                CustomHttpHeaderProvider = null
            };

            var httpClient = httpClientFactory.Create(apiUri);
            var client     = new UnleashApiClient(httpClient, jsonSerializer, requestHeaders);

            return(client);
        }
Ejemplo n.º 2
0
        public void Asserter()
        {
            JsonSerializerTester.Assert(new JsonNetSerializer());

            var serializer = new DynamicNewtonsoftJsonSerializer();

            serializer.TryLoad();
            JsonSerializerTester.Assert(serializer);
        }
Ejemplo n.º 3
0
        private static IUnleashApiClient CreateApiClient()
        {
            var apiUri = new Uri("http://unleash.herokuapp.com/api/");

            var jsonSerializer = new DynamicNewtonsoftJsonSerializer();

            jsonSerializer.TryLoad();

            var httpClientFactory = new DefaultHttpClientFactory();

            var requestHeaders = new UnleashApiClientRequestHeaders
            {
                AppName           = "api-test-client",
                InstanceTag       = "instance1",
                CustomHttpHeaders = null
            };

            var httpClient = httpClientFactory.Create(apiUri);
            var client     = new UnleashApiClient(httpClient, jsonSerializer, requestHeaders);

            return(client);
        }
        private IUnleashApiClient CreateApiClient()
        {
            var jsonSerializer = new DynamicNewtonsoftJsonSerializer();

            jsonSerializer.TryLoad();

            var requestHeaders = new UnleashApiClientRequestHeaders
            {
                AppName                  = "api-test-client",
                InstanceTag              = "instance1",
                CustomHttpHeaders        = httpHeaders,
                CustomHttpHeaderProvider = httpHeadersProvider
            };

            var httpClient = new HttpClient(messageHandler)
            {
                BaseAddress = new Uri("http://example.com")
            };
            var client = new UnleashApiClient(httpClient, jsonSerializer, requestHeaders);

            return(client);
        }
        private UnleashApiClient NewTestableClient(string project, MockHttpMessageHandler messageHandler)
        {
            var apiUri = new Uri("http://unleash.herokuapp.com/api/");

            var jsonSerializer = new DynamicNewtonsoftJsonSerializer();

            jsonSerializer.TryLoad();

            var requestHeaders = new UnleashApiClientRequestHeaders
            {
                AppName                  = "api-test-client",
                InstanceTag              = "instance1",
                CustomHttpHeaders        = null,
                CustomHttpHeaderProvider = null
            };

            var httpClient = new HttpClient(messageHandler)
            {
                BaseAddress = apiUri,
                Timeout     = TimeSpan.FromSeconds(5)
            };

            return(new UnleashApiClient(httpClient, jsonSerializer, requestHeaders, project));
        }