public void EnableTemplatedConfiguration_NotFound_DontThrowException()
        {
            var keys = new Dictionary <string, string>
            {
                ["SomeKey"] = "GlobalValue",
                ["ThisKey"] = "{NOTAREALYKEY} change me"
            };

            var builder = new ConfigurationBuilder()
                          .AddInMemoryCollection(keys);

            IConfiguration configuration = builder.Build();
            var            settings      = new TemplateFormattedConfigurationSettings();

            settings.ThrowIfNotFound = false;

            configuration.EnableTemplatedConfiguration(settings);
            Assert.Equal(" change me", configuration["ThisKey"]);
        }
        public void EnableTemplatedConfiguration_ChangeTemplatedCharacters()
        {
            var keys = new Dictionary <string, string>
            {
                ["SomeKey"] = "GlobalValue",
                ["ThisKey"] = "(SomeKey) change me"
            };

            var builder = new ConfigurationBuilder()
                          .AddInMemoryCollection(keys);

            IConfiguration configuration = builder.Build();
            var            settings      = new TemplateFormattedConfigurationSettings();

            settings.TemplateCharacterStart = '(';
            settings.TemplateCharacterEnd   = ')';

            configuration.EnableTemplatedConfiguration(settings);
            Assert.Equal("GlobalValue change me", configuration["ThisKey"]);
        }
        public void EnableTemplatedConfiguration_EscapedDontRemove()
        {
            var keys = new Dictionary <string, string>
            {
                ["SomeKey"]   = "GlobalValue",
                ["SomeKey_2"] = "GlobalValue2",
                ["ThisKey"]   = "\\{SomeKey_2} change me"
            };

            var builder = new ConfigurationBuilder()
                          .AddInMemoryCollection(keys);

            IConfiguration configuration = builder.Build();
            var            settings      = new TemplateFormattedConfigurationSettings();

            settings.RemoveEscapedCharacters = false;

            configuration.EnableTemplatedConfiguration(settings);
            Assert.Equal("\\{SomeKey_2} change me", configuration["ThisKey"]);
        }