From 52401a43ac4adf988efa97512cacf1f1e8de45e6 Mon Sep 17 00:00:00 2001 From: Markus Ewald Date: Tue, 22 Jul 2014 22:04:16 +0000 Subject: [PATCH] The windows registry store can now enumerate non-existing categories, too git-svn-id: file:///srv/devel/repo-conversion/nusu@323 d2e56fa2-650e-0410-a79f-9358c0239efd --- Source/Settings/ConfigurationFileStore.Test.cs | 4 ++-- Source/Settings/WindowsRegistryStore.Test.cs | 10 ++++++++++ Source/Settings/WindowsRegistryStore.cs | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Source/Settings/ConfigurationFileStore.Test.cs b/Source/Settings/ConfigurationFileStore.Test.cs index 8e6cb67..fa00c1a 100644 --- a/Source/Settings/ConfigurationFileStore.Test.cs +++ b/Source/Settings/ConfigurationFileStore.Test.cs @@ -319,7 +319,7 @@ namespace Nuclex.Support.Settings { } /// - /// Verifies that it's possible to assign an empty value to an option + /// Verifies that options are removed from the configuration file correctly /// [Test] public void RemovingOptionShiftsFollowingOptionsUp() { @@ -355,7 +355,7 @@ namespace Nuclex.Support.Settings { } /// - /// Verifies that it's not an error to remove a non-existing option + /// Verifies that the configuration file store can identify various types of values /// [ Test, diff --git a/Source/Settings/WindowsRegistryStore.Test.cs b/Source/Settings/WindowsRegistryStore.Test.cs index 4c46c0c..d233ca6 100644 --- a/Source/Settings/WindowsRegistryStore.Test.cs +++ b/Source/Settings/WindowsRegistryStore.Test.cs @@ -180,6 +180,16 @@ namespace Nuclex.Support.Settings { } } + /// + /// Verifies that it's possible to enumerate a category that doesn't exist + /// + [Test] + public void NonExistingCategoryCanBeEnumerated() { + using(var context = new TestContext()) { + Assert.That(context.Store.EnumerateOptions("doesn't exist"), Is.Empty); + } + } + /// Verifies that byte arrays can be stored in the registry [Test] public void ByteArraysCanBeStored() { diff --git a/Source/Settings/WindowsRegistryStore.cs b/Source/Settings/WindowsRegistryStore.cs index 5720fa9..dff2609 100644 --- a/Source/Settings/WindowsRegistryStore.cs +++ b/Source/Settings/WindowsRegistryStore.cs @@ -82,6 +82,9 @@ namespace Nuclex.Support.Settings { } } else { using(RegistryKey categoryKey = this.rootKey.OpenSubKey(category, this.writable)) { + if(categoryKey == null) { + yield break; + } string[] valueNames = categoryKey.GetValueNames(); for(int index = 0; index < valueNames.Length; ++index) { yield return new OptionInfo() {