public static void ValidateEnvironmentVariables(string value) { // The parser will throw if the value is not well formed. var parser = new EnvironmentVariablesParser(null); parser.ParseEnvironmentVariablesString(value, ignoreErrors: false); }
private void CheckParserInvocation(string option, Action <IDictionary <string, string> > assertions, string errorMessage = null) { IDictionary <string, string> result; if (errorMessage == null) { result = _parser.ParseEnvironmentVariablesString(option); assertions(result); _fakeLogger.All.Should().BeEmpty(); return; } // logging result = _parser.ParseEnvironmentVariablesString(option); assertions(result); _fakeLogger.Warnings.Should().ContainSingle(); _fakeLogger.Warnings.Single().Should().Contain(errorMessage); // Exception _parser.Invoking(p => p.ParseEnvironmentVariablesString(option, false)) .Should().Throw <Exception>().WithMessage($"*{errorMessage}*"); }