예제 #1
0
        public void SetNullAndSaveDoesNothingWhenConfigEmpty()
        {
            StringKeeper keeper = CreateStringKeeper();

            keeper.Set(Key, null);
            keeper.Save();

            System.Configuration.Configuration config = CreateConfig();
            Assert.IsFalse(config.AppSettings.Settings.AllKeys.Any());
        }
예제 #2
0
        public void SetAndSaveSavesStringToConfig()
        {
            StringKeeper keeper = CreateStringKeeper();

            keeper.Set(Key, Value);
            keeper.Save();

            System.Configuration.Configuration config = CreateConfig();
            Assert.IsTrue(config.AppSettings.Settings.AllKeys.Count() == 1);
            Assert.AreEqual(Value, config.AppSettings.Settings[ConfigKey].Value);
        }
예제 #3
0
        public void SetNullAndSaveRemovesEntryFromConfig()
        {
            System.Configuration.Configuration config = CreateConfig();
            config.AppSettings.Settings.Add(ConfigKey, Value);
            config.Save();

            StringKeeper keeper = CreateStringKeeper();

            keeper.Set(Key, null);
            keeper.Save();

            config = CreateConfig();
            Assert.IsFalse(config.AppSettings.Settings.AllKeys.Any());
        }
예제 #4
0
        public void SetAndSaveReplacesEntryInConfig()
        {
            const string value        = "Value";
            const string anotherValue = "Another value";

            System.Configuration.Configuration config = CreateConfig();
            config.AppSettings.Settings.Add(ConfigKey, value);
            config.Save();

            StringKeeper keeper = CreateStringKeeper();

            keeper.Set(Key, anotherValue);
            keeper.Save();

            config = CreateConfig();
            Assert.IsTrue(config.AppSettings.Settings.AllKeys.Count() == 1);
            Assert.AreEqual(anotherValue, config.AppSettings.Settings[ConfigKey].Value);
        }