public void RemoveSettings()
        {
            RegistrySettingsStorage storage = new RegistrySettingsStorage("Test", testKey);

            storage.SaveSetting("X", 5);
            storage.SaveSetting("NAME", "Charlie");

            storage.RemoveSetting("X");
            Assert.IsNull(storage.LoadSetting("X"), "X not removed");
            Assert.AreEqual("Charlie", storage.LoadSetting("NAME"));

            storage.RemoveSetting("NAME");
            Assert.IsNull(storage.LoadSetting("NAME"), "NAME not removed");
        }
        public void DefaultSettings()
        {
            RegistrySettingsStorage storage = new RegistrySettingsStorage("Test", testKey);

            Assert.IsNull(storage.LoadSetting("X"));
            Assert.IsNull(storage.LoadSetting("NAME"));

            Assert.AreEqual(5, storage.LoadSetting("X", 5));
            Assert.AreEqual(6, storage.LoadIntSetting("X", 6));
            Assert.AreEqual("7", storage.LoadStringSetting("X", "7"));

            Assert.AreEqual("Charlie", storage.LoadSetting("NAME", "Charlie"));
            Assert.AreEqual("Fred", storage.LoadStringSetting("NAME", "Fred"));
        }
        public void TypeSafeSettings()
        {
            RegistrySettingsStorage storage = new RegistrySettingsStorage("Test", testKey);

            storage.SaveSetting("X", 5);
            storage.SaveSetting("Y", "17");
            storage.SaveSetting("NAME", "Charlie");

            Assert.AreEqual(5, storage.LoadSetting("X"));
            Assert.AreEqual(5, storage.LoadIntSetting("X"));
            Assert.AreEqual("5", storage.LoadStringSetting("X"));

            Assert.AreEqual("17", storage.LoadSetting("Y"));
            Assert.AreEqual(17, storage.LoadIntSetting("Y"));
            Assert.AreEqual("17", storage.LoadStringSetting("Y"));

            Assert.AreEqual("Charlie", storage.LoadSetting("NAME"));
            Assert.AreEqual("Charlie", storage.LoadStringSetting("NAME"));
        }
        public void SaveAndLoadSettings()
        {
            RegistrySettingsStorage storage = new RegistrySettingsStorage("Test", testKey);

            Assert.IsNull(storage.LoadSetting("X"), "X is not null");
            Assert.IsNull(storage.LoadSetting("NAME"), "NAME is not null");

            storage.SaveSetting("X", 5);
            storage.SaveSetting("NAME", "Charlie");

            Assert.AreEqual(5, storage.LoadSetting("X"));
            Assert.AreEqual("Charlie", storage.LoadSetting("NAME"));

            using (RegistryKey key = testKey.OpenSubKey("Test"))
            {
                Assert.IsNotNull(key);
                Assert.AreEqual(5, key.GetValue("X"));
                Assert.AreEqual("Charlie", key.GetValue("NAME"));
            }
        }