public void GetConfigValue( [Values("true", "false", null)] string enableSwitch, [Values("true", "false", null)] string enableEnvVar) { TestAppContextSwitch ctx = null; TestEnvVar env = null; try { bool actual; bool expected = enableSwitch switch { "true" => true, "false" => false, _ => bool.TryParse(enableEnvVar, out bool val) && val }; if (enableSwitch != null) { ctx = new TestAppContextSwitch(switchName, enableSwitch); } if (enableEnvVar != null) { env = new TestEnvVar(envVarName, enableEnvVar); } actual = AppContextSwitchHelper.GetConfigValue(switchName, envVarName); Assert.AreEqual(expected, actual); } finally { ctx?.Dispose(); env?.Dispose(); } }
public async Task CookiesCanBeEnabledUsingEnvVar() { using var envVar = new TestEnvVar("AZURE_CORE_HTTPCLIENT_ENABLE_COOKIES", "true"); await TestCookiesEnabled(); }