Skip to content

Instantly share code, notes, and snippets.

@BadgerCode
Last active April 2, 2019 08:51
Show Gist options
  • Save BadgerCode/e2b12a96728fd1d8774f5d455f952f75 to your computer and use it in GitHub Desktop.
Save BadgerCode/e2b12a96728fd1d8774f5d455f952f75 to your computer and use it in GitHub Desktop.
Loads test configuration into environment variables. Useful for .net core apps. Call this once before all your tests run.
public static class Configuration
{
public static void Load()
{
var config = JObject.Parse(File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "acceptance.settings.json")));
foreach (var configOption in config["Values"])
{
var option = (JProperty)configOption;
var key = option.Name;
var value = option.Value.ToString();
Environment.SetEnvironmentVariable(key, value, EnvironmentVariableTarget.Process);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment