diff options
Diffstat (limited to 'src/Microsoft.Win32.Registry/tests/RegistryKey/RegistryKeyDeleteSubKeyTestsBase.cs')
-rw-r--r-- | src/Microsoft.Win32.Registry/tests/RegistryKey/RegistryKeyDeleteSubKeyTestsBase.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Microsoft.Win32.Registry/tests/RegistryKey/RegistryKeyDeleteSubKeyTestsBase.cs b/src/Microsoft.Win32.Registry/tests/RegistryKey/RegistryKeyDeleteSubKeyTestsBase.cs new file mode 100644 index 0000000000..9ed116f3ce --- /dev/null +++ b/src/Microsoft.Win32.Registry/tests/RegistryKey/RegistryKeyDeleteSubKeyTestsBase.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using Xunit; + +namespace Microsoft.Win32.RegistryTests +{ + public abstract class RegistryKeyDeleteSubKeyTestsBase : RegistryTestsBase + { + protected void Verify_DeleteSubKey_KeyExists_KeyDeleted(string expected, Action deleteSubKey) + { + CreateTestRegistrySubKey(expected); + + deleteSubKey(); + Assert.Null(TestRegistryKey.OpenSubKey(expected)); + } + + protected void Verify_DeleteSubKey_KeyDoesNotExists_Throws(string expected, Action deleteSubKey) + { + Assert.Null(TestRegistryKey.OpenSubKey(expected)); + Assert.Equal(0, TestRegistryKey.SubKeyCount); + + Assert.Throws<ArgumentException>(() => deleteSubKey()); + } + + protected void Verify_DeleteSubKey_KeyDoesNotExists_DoesNotThrow(string expected, Action deleteSubKey) + { + Assert.Null(TestRegistryKey.OpenSubKey(expected)); + Assert.Equal(0, TestRegistryKey.SubKeyCount); + + deleteSubKey(); + } + } +} |