public void ShouldReadEnvironmentVariable()
        {
            var reader = new EnvironmentValueReader(_coreDependencies.DiagnosticLogging);
            var result = reader.GetEnvironmentValueThatIsNotEmpty(new string[] { "PATH", "path" });

            Assert.NotNull(result);
        }
        public void ShouldNotReadNonExistentEnvironmentVariable()
        {
            var reader = new EnvironmentValueReader(_coreDependencies.DiagnosticLogging);
            var result = reader.GetEnvironmentValueThatIsNotEmpty(new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() });

            Assert.Null(result);
        }
Exemple #3
0
        public static string TryGetEnvironmentVariableElseUseConfig(this string[] environmentVariables)
        {
            var reader = new EnvironmentValueReader();
            var val    = reader.GetEnvironmentValueThatIsNotEmpty(environmentVariables);

            if (!string.IsNullOrWhiteSpace(val))
            {
                return(val);
            }

            foreach (var ev in environmentVariables)
            {
                val = ConfigReader.Configuration[ev];
                if (!string.IsNullOrWhiteSpace(val))
                {
                    return(val);
                }
            }
            return(null);
        }