private void CheckCompilationResult( IDictionary <string, string> keys, IDictionary <string, string> structKeys, IDictionary <string, string> structVars, IDictionary <string, string> secrets, Action <CompilationResult> assertions, Func <IConfigurationCompiler, IConfigurationParser, EnvironmentCompilationInfo, StructureCompilationInfo, CompilationResult> compileFunc = null, [CallerMemberName] string testName = null) { var provider = new ServiceCollection().AddLogging(builder => builder.AddConsole().SetMinimumLevel(LogLevel.Warning)) .AddTransient <ISecretConfigValueProvider, TestSecretProvider>(p => new TestSecretProvider(secrets)) .BuildServiceProvider(); var compilerLogger = provider.GetRequiredService <ILogger <ConfigurationCompiler> >(); var resolverLogger = provider.GetRequiredService <ILogger <IValueResolver> >(); var secretProvider = provider.GetRequiredService <ISecretConfigValueProvider>(); IConfigurationCompiler compiler = new ConfigurationCompiler(secretProvider, compilerLogger, resolverLogger); IConfigurationParser parser = new AntlrConfigurationParser(); var env = new EnvironmentCompilationInfo { Keys = new ReadOnlyDictionary <string, string>(keys), Name = $"{testName}-Environment" }; var structure = new StructureCompilationInfo { Keys = new ReadOnlyDictionary <string, string>(structKeys), Variables = new ReadOnlyDictionary <string, string>(structVars), Name = $"{testName}-Structure" }; var compiled = compileFunc?.Invoke(compiler, parser, env, structure) ?? compiler.Compile(env, structure, parser); assertions(compiled); }
public ConfigValueParserTests() { _parser = new AntlrConfigurationParser(); }