Last active
April 2, 2019 08:51
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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