private static async Task GetValueAsyncAndAssert(IConfigCatClient client, string key, string defaultValue, string expectedValue)
        {
            var actual = await client.GetValueAsync(key, defaultValue);

            Assert.AreEqual(expectedValue, actual);
            Assert.AreNotEqual(defaultValue, actual);
        }
        private static void GetValueAndAssert(IConfigCatClient client, string key, string defaultValue, string expectedValue)
        {
            var actual = client.GetValue(key, defaultValue);

            Assert.AreEqual(expectedValue, actual);
            Assert.AreNotEqual(defaultValue, actual);
        }
        private void ClientDeadlockCheck(IConfigCatClient client)
        {
            var methods = typeof(IConfigCatClient).GetMethods().Where(x => !x.IsSpecialName).OrderBy(o => o.Name);

            foreach (var m in methods)
            {
                var parameters = Enumerable.Repeat <object>(null, m.GetParameters().Length).ToArray();

                MethodInfo mi = m;

                if (m.IsGenericMethod)
                {
                    mi = m.MakeGenericMethod(typeof(string));
                }

                Console.WriteLine($"Invoke '{mi.Name}' method");

                if (mi.ReturnType.IsSubclassOf(typeof(Task)))
                {
                    var task = (Task)mi.Invoke(client, parameters);

                    task.ConfigureAwait(false);
                    task.Wait();
                }
                else
                {
                    mi.Invoke(client, parameters);
                }

                syncContextMock.Verify(x => x.Post(It.IsAny <SendOrPostCallback>(), It.IsAny <object>()), Times.Never, $"Method: {mi.Name}");
                syncContextMock.Verify(x => x.Send(It.IsAny <SendOrPostCallback>(), It.IsAny <object>()), Times.Never, $"Method: {mi.Name}");
            }
        }
        public void LazyLoadGetValue()
        {
            IConfigCatClient client = ConfigCatClientBuilder
                                      .Initialize(APIKEY)
                                      .WithLazyLoad()
                                      .WithCacheTimeToLiveSeconds(30)
                                      .Create();

            GetValueAndAssert(client, "stringDefaultCat", "N/A", "Cat");
        }
        public void ManualPollGetValue()
        {
            IConfigCatClient manualPollClient = ConfigCatClientBuilder
                                                .Initialize(APIKEY)
                                                .WithManualPoll()
                                                .Create();

            manualPollClient.ForceRefresh();

            GetValueAndAssert(manualPollClient, "stringDefaultCat", "N/A", "Cat");
        }
        public void AutoPollGetValue()
        {
            IConfigCatClient client = ConfigCatClientBuilder
                                      .Initialize(APIKEY)
                                      .WithAutoPoll()
                                      .WithMaxInitWaitTimeSeconds(30)
                                      .WithPollIntervalSeconds(600)
                                      .Create();

            GetValueAndAssert(client, "stringDefaultCat", "N/A", "Cat");
        }
Esempio n. 7
0
        public async Task LazyLoadGetValueAsync()
        {
            IConfigCatClient client = ConfigCatClientBuilder
                                      .Initialize(SDKKEY)
                                      .WithLogger(consoleLogger)
                                      .WithLazyLoad()
                                      .WithCacheTimeToLiveSeconds(30)
                                      .Create();

            await GetValueAsyncAndAssert(client, "stringDefaultCat", "N/A", "Cat");
        }
        public async Task ManualPollGetValueAsync()
        {
            IConfigCatClient client = ConfigCatClientBuilder
                                      .Initialize(APIKEY)
                                      .WithManualPoll()
                                      .Create();

            await client.ForceRefreshAsync();

            await GetValueAsyncAndAssert(client, "stringDefaultCat", "N/A", "Cat");
        }
Esempio n. 9
0
        public async Task AutoPollGetValueAsync()
        {
            IConfigCatClient client = ConfigCatClientBuilder
                                      .Initialize(SDKKEY)
                                      .WithLogger(consoleLogger)
                                      .WithAutoPoll()
                                      .WithMaxInitWaitTimeSeconds(30)
                                      .WithPollIntervalSeconds(600)
                                      .Create();

            await GetValueAsyncAndAssert(client, "stringDefaultCat", "N/A", "Cat");
        }
Esempio n. 10
0
        public void GetVariationId()
        {
            IConfigCatClient manualPollClient = ConfigCatClientBuilder
                                                .Initialize(SDKKEY)
                                                .WithLogger(consoleLogger)
                                                .WithManualPoll()
                                                .Create();

            manualPollClient.ForceRefresh();
            var actual = manualPollClient.GetVariationId("stringDefaultCat", "default");

            Assert.AreEqual("7a0be518", actual);
        }
Esempio n. 11
0
        public void GetAllKeys()
        {
            IConfigCatClient manualPollClient = ConfigCatClientBuilder
                                                .Initialize(SDKKEY)
                                                .WithLogger(consoleLogger)
                                                .WithManualPoll()
                                                .Create();

            manualPollClient.ForceRefresh();
            var keys = manualPollClient.GetAllKeys().ToArray();

            Assert.AreEqual(16, keys.Count());
            Assert.IsTrue(keys.Contains("stringDefaultCat"));
        }
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            IConfigCatClient configCatClient = context.HttpContext.RequestServices.GetService(typeof(IConfigCatClient)) as IConfigCatClient;


            if (configCatClient != null)
            {
                configCatClient.ForceRefresh();

                if (!configCatClient.GetValue(ApplicationConstants.FeatureToggle.ACAO_EXCLUIR, false))
                {
                    context.Result = new NotFoundResult();
                }
            }
        }
Esempio n. 13
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            IConfigCatClient configCatClient = context.HttpContext.RequestServices.GetService(typeof(IConfigCatClient)) as IConfigCatClient;


            if (configCatClient != null)
            {
                configCatClient.ForceRefresh();

                if (!configCatClient.GetValue(_toggleName, false))
                {
                    context.Result = new NotFoundResult();
                }
            }
        }
Esempio n. 14
0
        public async Task GetAllVariationIdAsync()
        {
            // Arrange

            const string expectedJsonString = "[\"7a0be518\",\"83372510\",\"2459598d\",\"ce564c3a\",\"44ab483a\",\"d227b334\",\"93f5a1c0\",\"bb66b1f3\",\"09513143\",\"489a16d2\",\"607147d5\",\"11634414\",\"faadbf54\",\"5af8acc7\",\"183ee713\",\"baff2362\"]";

            var expectedValue = Newtonsoft.Json.JsonConvert.DeserializeObject <string[]>(expectedJsonString);

            IConfigCatClient manualPollClient = ConfigCatClientBuilder
                                                .Initialize(SDKKEY)
                                                .WithLogger(consoleLogger)
                                                .WithManualPoll()
                                                .Create();

            await manualPollClient.ForceRefreshAsync();

            // Act

            var actual = await manualPollClient.GetAllVariationIdAsync(new User("*****@*****.**"));

            // Assert
            Assert.AreEqual(16, expectedValue.Length);
            CollectionAssert.AreEquivalent(expectedValue, actual.ToArray());
        }
 public FeatureToggleClient(IConfigCatClient configCatClient)
 {
     _configCatClient = configCatClient;
 }
Esempio n. 16
0
 public MainPage()
 {
     InitializeComponent();
     client = new ConfigCatClient(clientConfiguration);
 }
Esempio n. 17
0
 public HomeController(IGithubAPIService service, IHostingEnvironment env, IConfigCatClient client)
 {
     _service     = service;
     _environment = env;
     _client      = client;
 }
 public ConfigCatConfiguration(IConfigCatClient catClient, string key)
 {
     _catClient = catClient;
     _key       = key;
 }
Esempio n. 19
0
 public HomeController(IConfigCatClient configCatClient)
 {
     this.configCatClient = configCatClient;
 }
 public FeatureFlagsManagmentController(IConfigCatClient client)
 {
     _client = client;
 }
Esempio n. 21
0
 public BackdoorController(IConfigCatClient configCatClient)
 {
     this.configCatClient = configCatClient;
 }
Esempio n. 22
0
 public FeatureFlagProvider(IConfigCatClient configCatClient)
 {
     _configCatClient = configCatClient;
 }