Ejemplo n.º 1
0
        private static EnvironmentSettings GetEnvironmentSettings(ITestLogger logger)
        {
            IConfiguration configuration = new ConfigurationBuilder()
                                           .SetBasePath(Directory.GetCurrentDirectory())
                                           .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                                           .Build();

            var environment = Environment.GetEnvironmentVariable(EnvironmentAttributeKey)
                              ?? configuration[EnvironmentAttributeKey]
                              ?? "dev";

            logger.LogLine(FormattableString.Invariant($"[{nameof(TestModule)}]: Using '{environment}' environment configuration."));

            return(new EnvironmentSettings()
            {
                BaseUrl = configuration["EnvironmentSettings:BaseUrl"]
            });
        }