public void ShouldAddMissingAppSettings()
        {
            // Arrange
            var appSettings = new AppSettingsSection();
            var coll        = new NameValueCollection()
            {
                { IniConfigurationBuilder.locationTag, iniFileLocation },
                { IniConfigurationBuilder.modeTag, KeyValueMode.Greedy.ToString() }
            };
            var sut = new IniConfigurationBuilder();

            sut.Initialize("test", coll);

            // Act
            sut.ProcessConfigurationSection(appSettings);

            // Assert
            Assert.AreEqual(3, appSettings.Settings.Count, "Did not add more add nodes to appSettings");

            // Check for the other three settings
            for (int i = 1; i < 4; i++)
            {
                Assert.IsNotNull(appSettings.Settings[$"setting{i}"], $"Missing setting{i}");
            }
        }
        public void ShouldApplyAppSettingsToAppSettings()
        {
            // Arrange
            var appSettings = new AppSettingsSection();
            var sut         = new IniConfigurationBuilder();

            sut.Initialize("test", Settings);

            // Act
            sut.ProcessConfigurationSection(appSettings);

            // Assert
            Assert.AreEqual(3, appSettings.Settings.Count, "Did not add more add nodes to appSettings");
        }
Exemple #3
0
        public void DoesNotApplySettingIfNoSettingFound()
        {
            // Arrange
            var appSettings = new AppSettingsSection();

            appSettings.Settings.Add("NotFoundSetting", "inlineValue");
            var coll = new NameValueCollection()
            {
                { IniConfigurationBuilder.locationTag, iniFileLocation }
            };
            var sut = new IniConfigurationBuilder();

            sut.Initialize("test", coll);

            // Act
            sut.ProcessConfigurationSection(appSettings);

            // Assert
            Assert.AreEqual("inlineValue", appSettings.Settings["NotFoundSetting"].Value, "Changed the value when it shouldn't have");
        }
Exemple #4
0
        public void AppliesSetting()
        {
            // Arrange
            var appSettings = new AppSettingsSection();

            appSettings.Settings.Add("setting", "inlineValue");
            var coll = new NameValueCollection()
            {
                { IniConfigurationBuilder.locationTag, iniFileLocation }
            };
            var sut = new IniConfigurationBuilder();

            sut.Initialize("test", coll);

            // Act
            sut.ProcessConfigurationSection(appSettings);

            // Assert
            Assert.AreEqual("CorrectTestResult", appSettings.Settings["setting"].Value, "Did not set the value properly on the value");
        }
        public void ShouldApplySectionName()
        {
            // Arrange
            var appSettings = new AppSettingsSection();

            appSettings.Settings.Add("appSettings_appsetting1", "inlineValue");
            appSettings.Settings.Add("appSettings_appsetting2", "inlineValue");
            var coll = new NameValueCollection()
            {
                { IniConfigurationBuilder.locationTag, iniFileLocation }
            };
            var sut = new IniConfigurationBuilder();

            sut.Initialize("test", coll);

            // Act
            sut.ProcessConfigurationSection(appSettings);

            // Assert
            Assert.AreEqual("value1", appSettings.Settings["appSettings_appsetting1"].Value, "Did not set the value properly on the value");
            Assert.AreEqual("value2", appSettings.Settings["appSettings_appsetting2"].Value, "Did not set the value properly on the value");
        }