Debian Codegraph @

external/corefx/src/Microsoft.Win32.Registry/tests/RegistryKey/RegistryKeyDeleteSubKeyTestsBase.cs

raw
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4
5 using System;
6 using Xunit;
7
8 namespace Microsoft.Win32.RegistryTests
9 {
10 public abstract class RegistryKeyDeleteSubKeyTestsBase : RegistryTestsBase
11 {
12 protected void Verify_DeleteSubKey_KeyExists_KeyDeleted(string expected, Action deleteSubKey)
13 {
14 CreateTestRegistrySubKey(expected);
15
16 deleteSubKey();
17 Assert.Null(TestRegistryKey.OpenSubKey(expected));
18 }
19
20 protected void Verify_DeleteSubKey_KeyDoesNotExists_Throws(string expected, Action deleteSubKey)
21 {
22 Assert.Null(TestRegistryKey.OpenSubKey(expected));
23 Assert.Equal(0, TestRegistryKey.SubKeyCount);
24
25 AssertExtensions.Throws<ArgumentException>(null, () => deleteSubKey());
26 }
27
28 protected void Verify_DeleteSubKey_KeyDoesNotExists_DoesNotThrow(string expected, Action deleteSubKey)
29 {
30 Assert.Null(TestRegistryKey.OpenSubKey(expected));
31 Assert.Equal(0, TestRegistryKey.SubKeyCount);
32
33 deleteSubKey();
34 }
35 }
36 }