public void GetChildren_WithSection_ReturnsAllDescendents()
        {
            var configManagerFixture = new ConfigurationManagerFixture();

            int numKeys = new Random().Next(1, 10);

            for (int keyCt = 1; keyCt <= numKeys; keyCt++)
            {
                configManagerFixture.WithAppSetting($"Key{keyCt}", $"Value{keyCt}");
                configManagerFixture.WithAppSetting($"Section:Key{keyCt}", $"Value{keyCt}");
                configManagerFixture.WithAppSetting($"Section:SubSection:Key{keyCt}", $"Value{keyCt}");
                configManagerFixture.WithAppSetting($"OtherSection:Key{keyCt}", $"Value{keyCt}");
            }

            IConfigurationManager configManager = configManagerFixture.Build();

            var appConfig = new AppConfiguration(configManager);

            IAppConfigurationSection section = appConfig.GetSection("Section");

            int actual = section.GetChildren().Count();

            const int numSections = 2;
            int       expected    = numKeys * numSections;

            Assert.That(actual, Is.EqualTo(expected));
        }
        public void GetSection_WithSubSection_ReturnsSubSectionWithKeys()
        {
            var configManagerFixture = new ConfigurationManagerFixture();

            int numKeys = new Random().Next(1, 10);

            for (int keyCt = 1; keyCt <= numKeys; keyCt++)
            {
                configManagerFixture.WithAppSetting(AppConfigurationPath.Combine("Section", $"Key{keyCt}"), $"Value{keyCt}");
                configManagerFixture.WithAppSetting(AppConfigurationPath.Combine("Section:SubSection", $"Key{keyCt}"), $"Value{keyCt}");
                configManagerFixture.WithAppSetting(AppConfigurationPath.Combine("Section:OtherSubSection", $"Key{keyCt}"), $"Value{keyCt}");
            }

            IConfigurationManager configManager = configManagerFixture.Build();

            var appConfig = new AppConfiguration(configManager);

            IAppConfigurationSection section    = appConfig.GetSection("Section");
            IAppConfigurationSection subSection = section.GetSection("SubSection");

            int actual = subSection.GetChildren().Count();

            Assert.That(actual, Is.EqualTo(numKeys));
        }
        public void GetSection_WithSection_ReturnsSectionWithKeys(string sectionKey, string key, string value)
        {
            var configManagerFixture = new ConfigurationManagerFixture();

            int numKeys = new Random().Next(1, 10);

            for (int keyCt = 1; keyCt <= numKeys; keyCt++)
            {
                configManagerFixture.WithAppSetting(AppConfigurationPath.Combine(sectionKey, $"{key}{keyCt}"), $"{value}{keyCt}");
            }

            IConfigurationManager configManager = configManagerFixture.Build();

            var appConfig = new AppConfiguration(configManager);

            IAppConfigurationSection section = appConfig.GetSection(sectionKey);

            int actual = section.GetChildren().Count();

            Assert.That(actual, Is.EqualTo(numKeys));
        }