コード例 #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);
        }