public void CanAddMultiLevelKeys()
        {
            try
            {
                using (var source = new RegistryConfigurationSource(FullTestKeyName(TestKeyName)))
                {
                    source.Sections[SectionName].Set("key", "value");
                    source.Add(new ConfigurationSection("NewSettings"));
                    source.Sections["NewSettings"].Set("count", 5);
                    source.Add(new ConfigurationSection("NewSettings\\Legacy"));
                    source.Sections["NewSettings\\Legacy"].Set("count", 5);
                    source.Save();
                }

                var root = TestKeyName;
                Assert.True(KeyExists(root));
                Assert.False(KeyExists(string.Format("{0}\\{1}", root, SectionName)));
                Assert.True(KeyExists(root + "\\NewSettings"));
                Assert.True(KeyExists(root + "\\NewSettings\\Legacy"));
            }
            finally
            {
                DeleteKey(TestKeyName);
            }
        }
        public void CanLoadMultiLevelKeys()
        {
            try
            {
                using (var source = new RegistryConfigurationSource(FullTestKeyName(TestKeyName)))
                {
                    source.Sections[SectionName].Set("key", "value");
                    source.Add(new ConfigurationSection("NewSettings"));
                    source.Sections["NewSettings"].Set("count", 5);
                    source.Add(new ConfigurationSection("NewSettings\\Legacy"));
                    source.Sections["NewSettings\\Legacy"].Set("count", 15);
                    source.Save();
                }
                using (var source = new RegistryConfigurationSource(FullTestKeyName(TestKeyName)))
                {
                    Assert.Equal(3, source.Sections.Count);

                    Assert.Equal("NewSettings\\Legacy", source.Sections.ToList()[0].Value.Name);
                    Assert.Equal(15, source.Sections["NewSettings\\Legacy"].Get <int>("count"));

                    Assert.Equal("NewSettings", source.Sections.ToList()[1].Value.Name);
                    Assert.Equal(5, source.Sections["NewSettings"].Get <int>("count"));

                    Assert.Equal(SectionName, source.Sections.ToList()[2].Value.Name);
                    Assert.Equal("value", source.Sections[SectionName].Get <string>("key"));
                }
            }
            finally
            {
                DeleteKey(TestKeyName);
            }
        }
        public void CanAddNewKeys()
        {
            try
            {
                using ( var source = new RegistryConfigurationSource( FullTestKeyName( TestKeyName ) ) )
                {
                    source.Sections[SectionName].Set( "key", "value" );
                    source.Add( new ConfigurationSection( "NewSettings" ) );
                    source.Sections["NewSettings"].Set( "count", 5 );
                    source.Save();
                }

                var root = TestKeyName;
                Assert.True( KeyExists( root ) );
                Assert.False( KeyExists( string.Format( "{0}\\{1}", root, SectionName ) ) );
                Assert.True( KeyExists( root + "\\NewSettings" ) );
            }
            finally
            {
                DeleteKey( TestKeyName );
            }
        }
        public void CanLoadKeys()
        {
            try
            {
                using ( var source = new RegistryConfigurationSource( FullTestKeyName( TestKeyName ) ) )
                {
                    source.Sections[SectionName].Set( "key", "value" );
                    source.Add( new ConfigurationSection( "NewSettings" ) );
                    source.Sections["NewSettings"].Set( "count", 5 );
                    source.Save();
                }
                using ( var source = new RegistryConfigurationSource( FullTestKeyName( TestKeyName ) ) )
                {
                    Assert.Equal( 2, source.Sections.Count );

                    Assert.Equal( "NewSettings", source.Sections.ToList()[0].Value.Name );
                    Assert.Equal( 5, source.Sections["NewSettings"].Get<int>( "count" ) );

                    Assert.Equal( SectionName, source.Sections.ToList()[1].Value.Name );
                    Assert.Equal( "value", source.Sections[SectionName].Get<string>( "key" ) );
                }
            }
            finally
            {
                DeleteKey( TestKeyName );
            }
        }