Ejemplo n.º 1
0
        public async Task WithDataGovernanceSetting_ShouldUseProperCdnUrl(DataGovernance dataGovernance, string expectedUrl)
        {
            // Arrange

            var configuration = new AutoPollConfiguration
            {
                SdkKey         = "DEMO",
                DataGovernance = dataGovernance
            };

            byte requestCount = 0;
            var  requests     = new SortedList <byte, HttpRequestMessage>();

            var handlerMock = new Mock <HttpClientHandler>(MockBehavior.Strict);

            handlerMock
            .Protected()
            .Setup <Task <HttpResponseMessage> >(
                "SendAsync",
                ItExpr.IsAny <HttpRequestMessage>(),
                ItExpr.IsAny <CancellationToken>()
                )
            .Callback <HttpRequestMessage, CancellationToken>((message, _) =>
            {
                requests.Add(requestCount++, message);
            })
            .ReturnsAsync(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("{\"p\": {\"u\": \"http://example.com\", \"r\": 0}}"),
            })
            .Verifiable();

            IConfigFetcher fetcher = new HttpConfigFetcher(
                configuration.CreateUri(),
                "DEMO",
                Mock.Of <ILogger>(),
                handlerMock.Object,
                Mock.Of <IConfigDeserializer>(),
                configuration.IsCustomBaseUrl);

            // Act

            await fetcher.Fetch(ProjectConfig.Empty);

            // Assert

            handlerMock.VerifyAll();
            Assert.AreEqual(1, requestCount);
            Assert.AreEqual(new Uri(expectedUrl).Host, requests[0].RequestUri.Host);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Create an instance of ConfigCatClient and setup AutoPoll mode
 /// </summary>
 /// <param name="sdkKey">SDK Key to access configuration</param>
 /// <param name="dataGovernance">Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard: https://app.configcat.com/organization/data-governance (Only Organization Admins have access)</param>
 /// <exception cref="ArgumentException">When the <paramref name="sdkKey"/> is null or empty</exception>
 public ConfigCatClient(string sdkKey, DataGovernance dataGovernance = DataGovernance.Global) : this(new AutoPollConfiguration {
     SdkKey = sdkKey, DataGovernance = dataGovernance
 })
 {
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Set <see cref="DataGovernance" />
        /// </summary>
        /// <param name="dataGovernance">Describes the location of your feature flag and setting data within the ConfigCat CDN.</param>
        /// <returns></returns>
        public ConfigCatClientBuilder WithDataGovernance(DataGovernance dataGovernance)
        {
            this.DataGovernance = dataGovernance;

            return(this);
        }