public void AddConfigNoDefaultKey()
        {
            var source = new RegistryConfigSource();

            source.AddMapping(Registry.LocalMachine, "Software\\Tests\\NiniTestApp\\Pets");

            Assert.Throws <ApplicationException>(() => source.AddConfig("People"));
        }
示例#2
0
        public void AddConfigNoDefaultKey()
        {
            RegistryConfigSource source = new RegistryConfigSource();

            source.AddMapping(Registry.LocalMachine, "Software\\NiniTestApp\\Pets");

            IConfig config = source.AddConfig("People");
        }
        public void AddConfig()
        {
            var source = new RegistryConfigSource();
            var key    = Registry.LocalMachine.OpenSubKey("Software\\Tests\\NiniTestApp", true);

            var config = source.AddConfig("People", key);

            config.Set("woman", "Tara");
            config.Set("man", "Quentin");

            source.Save();

            source = new RegistryConfigSource();
            source.AddMapping(Registry.LocalMachine, "Software\\Tests\\NiniTestApp\\People");

            Assert.AreEqual(1, source.Configs.Count);
            config = source.Configs["People"];
            Assert.AreEqual(2, config.GetKeys().Length);
            Assert.AreEqual("Tara", config.Get("woman"));
            Assert.AreEqual("Quentin", config.Get("man"));
        }