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"); }
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"); }
public async Task AutoPollGetValueAsync() { IConfigCatClient client = ConfigCatClientBuilder .Initialize(SDKKEY) .WithLogger(consoleLogger) .WithAutoPoll() .WithMaxInitWaitTimeSeconds(30) .WithPollIntervalSeconds(600) .Create(); await GetValueAsyncAndAssert(client, "stringDefaultCat", "N/A", "Cat"); }
public void GetVariationId() { IConfigCatClient manualPollClient = ConfigCatClientBuilder .Initialize(SDKKEY) .WithLogger(consoleLogger) .WithManualPoll() .Create(); manualPollClient.ForceRefresh(); var actual = manualPollClient.GetVariationId("stringDefaultCat", "default"); Assert.AreEqual("7a0be518", actual); }
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(); } } }
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(); } } }
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; }
public MainPage() { InitializeComponent(); client = new ConfigCatClient(clientConfiguration); }
public HomeController(IGithubAPIService service, IHostingEnvironment env, IConfigCatClient client) { _service = service; _environment = env; _client = client; }
public ConfigCatConfiguration(IConfigCatClient catClient, string key) { _catClient = catClient; _key = key; }
public HomeController(IConfigCatClient configCatClient) { this.configCatClient = configCatClient; }
public FeatureFlagsManagmentController(IConfigCatClient client) { _client = client; }
public BackdoorController(IConfigCatClient configCatClient) { this.configCatClient = configCatClient; }
public FeatureFlagProvider(IConfigCatClient configCatClient) { _configCatClient = configCatClient; }